Skip to content

Commit

Permalink
Fix after gocritic -enableAll
Browse files Browse the repository at this point in the history
  • Loading branch information
Oskar Sharipov committed Jul 28, 2022
1 parent 5384b1c commit 03cdf8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
15 changes: 4 additions & 11 deletions base.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package minitrust

import (
"errors"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand All @@ -11,8 +10,8 @@ import (
)

const (
trustedDirPerm = 0700
trustedKeyPerm = 0600
trustedDirPerm = 0o700
trustedKeyPerm = 0o600
)

type Base struct {
Expand Down Expand Up @@ -66,12 +65,6 @@ func (b *Base) AddTrustedPubKey(rawPubKey, comment string) error {
return err
}

content := strings.Join(
[]string{
commentPrefix + comment,
EncodePublicKey(pk),
},
"\n",
)
return ioutil.WriteFile(b.getKeyPath(pk.KeyId), []byte(content), trustedKeyPerm)
content := commentPrefix + comment + "\n" + EncodePublicKey(pk)
return os.WriteFile(b.getKeyPath(pk.KeyId), []byte(content), trustedKeyPerm)
}
3 changes: 1 addition & 2 deletions pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"encoding/base64"
"encoding/binary"
"errors"
"io/ioutil"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -59,7 +58,7 @@ func DecodeKeyFileContent(in string) (minisign.PublicKey, string, error) {

// ReadKeyFile reads from keyPath and returns public key with untrusted comment.
func ReadKeyFile(keyPath string) (minisign.PublicKey, string, error) {
content, err := ioutil.ReadFile(keyPath)
content, err := os.ReadFile(keyPath)
if os.IsNotExist(err) {
return minisign.PublicKey{}, "", errors.New("minitrust: public key doesn't exist in trusted directory.")
} else if err != nil {
Expand Down

0 comments on commit 03cdf8f

Please sign in to comment.