Skip to content

Commit

Permalink
chore(core): cleanup
Browse files Browse the repository at this point in the history
* Fix deprecation of combra.ExactValidArgs

* Remove unreachable codepath

* Fix deprecation of ioutil

---------

Co-authored-by: 0WN463 <>
  • Loading branch information
0WN463 authored Dec 27, 2024
1 parent cd3d471 commit 98a3c59
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $ qrcp completion fish > ~/.config/fish/completions/qrcp.fish
`,
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.ExactValidArgs(1),
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
switch args[0] {
case "bash":
Expand Down
3 changes: 0 additions & 3 deletions cmd/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ func sendCmdFunc(command *cobra.Command, args []string) error {
return err
}
cfg := config.New(app)
if err != nil {
return err
}
srv, err := server.New(&cfg)
if err != nil {
return err
Expand Down
5 changes: 2 additions & 3 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package config

import (
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand All @@ -19,12 +18,12 @@ func TestNew(t *testing.T) {
panic(err)
}
testdir := filepath.Join(filepath.Dir(f), "testdata")
tempfile, err := ioutil.TempFile("", "qrcp*tmp.yml")
tempfile, err := os.CreateTemp("", "qrcp*tmp.yml")
if err != nil {
t.Skip()
}
defer os.Remove(tempfile.Name())
partialconfig, err := ioutil.TempFile("", "qrcp*partial.yml")
partialconfig, err := os.CreateTemp("", "qrcp*partial.yml")
if err != nil {
panic(err)
}
Expand Down
5 changes: 2 additions & 3 deletions config/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"

Expand All @@ -20,7 +19,7 @@ func Migrate(app application.App) (bool, error) {
if _, err := os.Stat(oldConfigFile); os.IsNotExist(err) {
return false, nil
}
oldConfigFileBytes, err := ioutil.ReadFile(oldConfigFile)
oldConfigFileBytes, err := os.ReadFile(oldConfigFile)
if err != nil {
panic(err)
}
Expand All @@ -32,7 +31,7 @@ func Migrate(app application.App) (bool, error) {
if err != nil {
panic(err)
}
if err := ioutil.WriteFile(newConfigFile, newConfigFileBytes, 0644); err != nil {
if err := os.WriteFile(newConfigFile, newConfigFileBytes, 0644); err != nil {
panic(err)
}
// Delete old file
Expand Down
3 changes: 1 addition & 2 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/base64"
"errors"
"io"
"io/ioutil"
"net"
"os"
"os/user"
Expand Down Expand Up @@ -158,7 +157,7 @@ func FindIP(iface net.Interface) (string, error) {

// ReadFilenames from dir
func ReadFilenames(dir string) []string {
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 98a3c59

Please sign in to comment.