diff --git a/cmd/syncthing/cli/operations.go b/cmd/syncthing/cli/operations.go index d84e67e15..a4c26da92 100644 --- a/cmd/syncthing/cli/operations.go +++ b/cmd/syncthing/cli/operations.go @@ -8,6 +8,7 @@ package cli import ( "bufio" + "errors" "fmt" "path/filepath" @@ -77,12 +78,12 @@ func foldersOverride(c *cli.Context) error { if body != "" { errStr += "\nBody: " + body } - return fmt.Errorf(errStr) + return errors.New(errStr) } return nil } } - return fmt.Errorf("Folder " + rid + " not found") + return fmt.Errorf("Folder %q not found", rid) } func setDefaultIgnores(c *cli.Context) error { diff --git a/cmd/syncthing/decrypt/decrypt.go b/cmd/syncthing/decrypt/decrypt.go index bb7651e72..1bb56c683 100644 --- a/cmd/syncthing/decrypt/decrypt.go +++ b/cmd/syncthing/decrypt/decrypt.go @@ -10,6 +10,7 @@ package decrypt import ( "encoding/binary" "encoding/json" + "errors" "fmt" "io" "log" @@ -45,7 +46,7 @@ func (c *CLI) Run() error { log.SetFlags(0) if c.To == "" && !c.VerifyOnly { - return fmt.Errorf("must set --to or --verify-only") + return errors.New("must set --to or --verify-only") } if c.TokenPath == "" { @@ -138,7 +139,7 @@ func (c *CLI) process(srcFs fs.Filesystem, dstFs fs.Filesystem, path string) err } defer encFd.Close() - encFi, err := c.loadEncryptedFileInfo(encFd) + encFi, err := loadEncryptedFileInfo(encFd) if err != nil { return fmt.Errorf("%s: loading metadata trailer: %w", path, err) } @@ -246,7 +247,7 @@ func (c *CLI) decryptFile(encFi *protocol.FileInfo, plainFi *protocol.FileInfo, // loadEncryptedFileInfo loads the encrypted FileInfo trailer from a file on // disk. -func (c *CLI) loadEncryptedFileInfo(fd fs.File) (*protocol.FileInfo, error) { +func loadEncryptedFileInfo(fd fs.File) (*protocol.FileInfo, error) { // Seek to the size of the trailer block if _, err := fd.Seek(-4, io.SeekEnd); err != nil { return nil, err diff --git a/cmd/syncthing/generate/generate.go b/cmd/syncthing/generate/generate.go index b3df5fe98..9afb170dc 100644 --- a/cmd/syncthing/generate/generate.go +++ b/cmd/syncthing/generate/generate.go @@ -11,6 +11,7 @@ import ( "bufio" "context" "crypto/tls" + "errors" "fmt" "log" "os" @@ -40,7 +41,7 @@ func (c *CLI) Run() error { if c.HomeDir != "" { if c.ConfDir != "" { - return fmt.Errorf("--home must not be used together with --config") + return errors.New("--home must not be used together with --config") } c.ConfDir = c.HomeDir } diff --git a/lib/protocol/deviceid.go b/lib/protocol/deviceid.go index 11ee13c51..5effb8e38 100644 --- a/lib/protocol/deviceid.go +++ b/lib/protocol/deviceid.go @@ -45,7 +45,7 @@ func DeviceIDFromString(s string) (DeviceID, error) { func DeviceIDFromBytes(bs []byte) (DeviceID, error) { var n DeviceID if len(bs) != len(n) { - return n, fmt.Errorf("incorrect length of byte slice representing device ID") + return n, errors.New("incorrect length of byte slice representing device ID") } copy(n[:], bs) return n, nil @@ -129,7 +129,7 @@ func (n *DeviceID) UnmarshalText(bs []byte) error { } } -func (n *DeviceID) ProtoSize() int { +func (*DeviceID) ProtoSize() int { // Used by protobuf marshaller. return DeviceIDLength }