From c50011bc36d5397a3495edb1a14d560f695c8960 Mon Sep 17 00:00:00 2001 From: kaiyou Date: Sun, 10 May 2020 18:23:46 +0200 Subject: [PATCH] Use errors.Wrap instead of manual formatting --- config.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index 037b1f1..2f4ea4f 100644 --- a/config.go +++ b/config.go @@ -6,6 +6,7 @@ import ( "github.com/costela/wesher/cluster" "github.com/hashicorp/go-sockaddr" + "github.com/pkg/errors" "github.com/stevenroose/gonfig" ) @@ -50,11 +51,11 @@ func loadConfig() (*config, error) { // Compute the actual bind address based on the provided interface iface, err := net.InterfaceByName(config.BindIface) if err != nil { - return nil, fmt.Errorf("could not get interface by name %s: %w", config.BindIface, err) + return nil, errors.Wrapf(err, "could not get interface by name %s", config.BindIface) } addrs, err := iface.Addrs() if err != nil { - return nil, fmt.Errorf("could not get addresses for interface %s: %w", config.BindIface, err) + return nil, errors.Wrapf(err, "could not get addresses for interface %s", config.BindIface) } if len(addrs) > 0 { if addr, ok := addrs[0].(*net.IPNet); ok {