Skip to content

Commit 98a3c59

Browse files
authored
chore(core): cleanup
* Fix deprecation of combra.ExactValidArgs * Remove unreachable codepath * Fix deprecation of ioutil --------- Co-authored-by: 0WN463 <>
1 parent cd3d471 commit 98a3c59

File tree

5 files changed

+6
-12
lines changed

5 files changed

+6
-12
lines changed

cmd/completion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ $ qrcp completion fish > ~/.config/fish/completions/qrcp.fish
4343
`,
4444
DisableFlagsInUseLine: true,
4545
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
46-
Args: cobra.ExactValidArgs(1),
46+
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
4747
Run: func(cmd *cobra.Command, args []string) {
4848
switch args[0] {
4949
case "bash":

cmd/send.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ func sendCmdFunc(command *cobra.Command, args []string) error {
2020
return err
2121
}
2222
cfg := config.New(app)
23-
if err != nil {
24-
return err
25-
}
2623
srv, err := server.New(&cfg)
2724
if err != nil {
2825
return err

config/config_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package config
22

33
import (
4-
"io/ioutil"
54
"os"
65
"path/filepath"
76
"reflect"
@@ -19,12 +18,12 @@ func TestNew(t *testing.T) {
1918
panic(err)
2019
}
2120
testdir := filepath.Join(filepath.Dir(f), "testdata")
22-
tempfile, err := ioutil.TempFile("", "qrcp*tmp.yml")
21+
tempfile, err := os.CreateTemp("", "qrcp*tmp.yml")
2322
if err != nil {
2423
t.Skip()
2524
}
2625
defer os.Remove(tempfile.Name())
27-
partialconfig, err := ioutil.TempFile("", "qrcp*partial.yml")
26+
partialconfig, err := os.CreateTemp("", "qrcp*partial.yml")
2827
if err != nil {
2928
panic(err)
3029
}

config/migrate.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package config
22

33
import (
44
"encoding/json"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87

@@ -20,7 +19,7 @@ func Migrate(app application.App) (bool, error) {
2019
if _, err := os.Stat(oldConfigFile); os.IsNotExist(err) {
2120
return false, nil
2221
}
23-
oldConfigFileBytes, err := ioutil.ReadFile(oldConfigFile)
22+
oldConfigFileBytes, err := os.ReadFile(oldConfigFile)
2423
if err != nil {
2524
panic(err)
2625
}
@@ -32,7 +31,7 @@ func Migrate(app application.App) (bool, error) {
3231
if err != nil {
3332
panic(err)
3433
}
35-
if err := ioutil.WriteFile(newConfigFile, newConfigFileBytes, 0644); err != nil {
34+
if err := os.WriteFile(newConfigFile, newConfigFileBytes, 0644); err != nil {
3635
panic(err)
3736
}
3837
// Delete old file

util/util.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/base64"
66
"errors"
77
"io"
8-
"io/ioutil"
98
"net"
109
"os"
1110
"os/user"
@@ -158,7 +157,7 @@ func FindIP(iface net.Interface) (string, error) {
158157

159158
// ReadFilenames from dir
160159
func ReadFilenames(dir string) []string {
161-
files, err := ioutil.ReadDir(dir)
160+
files, err := os.ReadDir(dir)
162161
if err != nil {
163162
panic(err)
164163
}

0 commit comments

Comments
 (0)