From c9cbc7b40316e9c121937d542d970e17b049c216 Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Wed, 29 Sep 2021 15:53:25 +0800 Subject: [PATCH] fmt.Errorf instead of errors.New --- chain/bridge.go | 3 +-- config/config.go | 3 +-- internal/warp/address.go | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/chain/bridge.go b/chain/bridge.go index 41b1150..bf64c5a 100644 --- a/chain/bridge.go +++ b/chain/bridge.go @@ -2,7 +2,6 @@ package chain import ( "context" - "errors" "fmt" "io" "io/ioutil" @@ -68,7 +67,7 @@ func BridgeWithConfig(ctx context.Context, chain config.Chain, d bool) error { } l, ok := d.(bridge.ListenConfig) if !ok || l == nil { - return errors.New("the last proxy could not listen") + return fmt.Errorf("the last proxy could not listen") } listenConfig = l } diff --git a/config/config.go b/config/config.go index 31d1c33..5c7dbe1 100644 --- a/config/config.go +++ b/config/config.go @@ -2,7 +2,6 @@ package config import ( "encoding/json" - "errors" "fmt" "log" "os" @@ -105,7 +104,7 @@ func (m Node) MarshalJSON() ([]byte, error) { func (m *Node) UnmarshalJSON(data []byte) error { if m == nil { - return errors.New("node: UnmarshalJSON on nil pointer") + return fmt.Errorf("node: UnmarshalJSON on nil pointer") } if len(data) > 0 { switch data[0] { diff --git a/internal/warp/address.go b/internal/warp/address.go index 4f5e31c..1f0ba89 100644 --- a/internal/warp/address.go +++ b/internal/warp/address.go @@ -2,7 +2,7 @@ package warp import ( "context" - "errors" + "fmt" "net" "sync" "sync/atomic" @@ -12,7 +12,7 @@ import ( ) var ( - ErrConnClosed = errors.New("use of closed network connection") + ErrConnClosed = fmt.Errorf("use of closed network connection") ) func ConnWithCloser(conn net.Conn, closer func() error) net.Conn {