all: Modernize error wrapping (#8491)
This replaces old style errors.Wrap with modern fmt.Errorf and removes the (direct) dependency on github.com/pkg/errors. A couple of cases are adjusted by hand as previously errors.Wrap(nil, ...) would return nil, which is not what fmt.Errorf does.
This commit is contained in:
@@ -10,6 +10,7 @@ package config
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@@ -19,8 +20,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/build"
|
||||
"github.com/syncthing/syncthing/lib/fs"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
@@ -116,13 +115,13 @@ func New(myID protocol.DeviceID) Configuration {
|
||||
func (cfg *Configuration) ProbeFreePorts() error {
|
||||
port, err := getFreePort("127.0.0.1", DefaultGUIPort)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get free port (GUI)")
|
||||
return fmt.Errorf("get free port (GUI): %w", err)
|
||||
}
|
||||
cfg.GUI.RawAddress = fmt.Sprintf("127.0.0.1:%d", port)
|
||||
|
||||
port, err = getFreePort("0.0.0.0", DefaultTCPPort)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "get free port (BEP)")
|
||||
return fmt.Errorf("get free port (BEP): %w", err)
|
||||
}
|
||||
if port == DefaultTCPPort {
|
||||
cfg.Options.RawListenAddresses = []string{"default"}
|
||||
|
||||
Reference in New Issue
Block a user