mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 23:00:58 +00:00
all: Clean up fmt.Errorf usage (#8309)
This commit is contained in:
parent
4031568cdf
commit
49488c0e71
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user