From d68366605e030a6d3aff2af43ff7392487ab2bdf Mon Sep 17 00:00:00 2001 From: Don Date: Fri, 18 Sep 2020 10:46:00 -0700 Subject: [PATCH] Remove pkg/errors Use the built in handling in Golang 1.13+. --- go.mod | 3 +-- go.sum | 2 -- template/template.go | 8 ++++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index c4009f8..72295c5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/drone/drone-template-lib -go 1.12 +go 1.13 require ( github.com/Masterminds/goutils v1.1.0 // indirect @@ -10,7 +10,6 @@ require ( github.com/google/uuid v1.1.1 // indirect github.com/huandu/xstrings v1.2.0 // indirect github.com/imdario/mergo v0.3.7 // indirect - github.com/pkg/errors v0.8.1 github.com/stretchr/testify v1.6.1 // indirect golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect diff --git a/go.sum b/go.sum index 1edaf64..acad2a2 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,6 @@ github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0 github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/template/template.go b/template/template.go index 936f7a2..f6bf093 100644 --- a/template/template.go +++ b/template/template.go @@ -15,13 +15,13 @@ package template import ( + "fmt" "io/ioutil" "net/http" "net/url" "strings" "github.com/aymerick/raymond" - "github.com/pkg/errors" ) // Render parses and executes a template, returning the results in string @@ -37,7 +37,7 @@ func Render(template string, payload interface{}) (s string, err error) { res, err := http.Get(template) if err != nil { - return s, errors.Wrap(err, "failed to fetch") + return s, fmt.Errorf("failed to fetch: %w", err) } defer res.Body.Close() @@ -45,7 +45,7 @@ func Render(template string, payload interface{}) (s string, err error) { out, err := ioutil.ReadAll(res.Body) if err != nil { - return s, errors.Wrap(err, "failed to read") + return s, fmt.Errorf("failed to read: %w", err) } template = string(out) @@ -53,7 +53,7 @@ func Render(template string, payload interface{}) (s string, err error) { out, err := ioutil.ReadFile(u.Path) if err != nil { - return s, errors.Wrap(err, "failed to read") + return s, fmt.Errorf("failed to read: %w", err) } template = string(out)