Remove pkg/errors

Use the built in handling in Golang 1.13+.
This commit is contained in:
Don 2020-09-18 10:46:00 -07:00
parent c67388feab
commit d68366605e
3 changed files with 5 additions and 8 deletions

3
go.mod
View File

@ -1,6 +1,6 @@
module github.com/drone/drone-template-lib module github.com/drone/drone-template-lib
go 1.12 go 1.13
require ( require (
github.com/Masterminds/goutils v1.1.0 // indirect github.com/Masterminds/goutils v1.1.0 // indirect
@ -10,7 +10,6 @@ require (
github.com/google/uuid v1.1.1 // indirect github.com/google/uuid v1.1.1 // indirect
github.com/huandu/xstrings v1.2.0 // indirect github.com/huandu/xstrings v1.2.0 // indirect
github.com/imdario/mergo v0.3.7 // indirect github.com/imdario/mergo v0.3.7 // indirect
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.6.1 // indirect github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect

2
go.sum
View File

@ -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/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 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= 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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 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= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

View File

@ -15,13 +15,13 @@
package template package template
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
"github.com/aymerick/raymond" "github.com/aymerick/raymond"
"github.com/pkg/errors"
) )
// Render parses and executes a template, returning the results in string // 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) res, err := http.Get(template)
if err != nil { if err != nil {
return s, errors.Wrap(err, "failed to fetch") return s, fmt.Errorf("failed to fetch: %w", err)
} }
defer res.Body.Close() defer res.Body.Close()
@ -45,7 +45,7 @@ func Render(template string, payload interface{}) (s string, err error) {
out, err := ioutil.ReadAll(res.Body) out, err := ioutil.ReadAll(res.Body)
if err != nil { if err != nil {
return s, errors.Wrap(err, "failed to read") return s, fmt.Errorf("failed to read: %w", err)
} }
template = string(out) template = string(out)
@ -53,7 +53,7 @@ func Render(template string, payload interface{}) (s string, err error) {
out, err := ioutil.ReadFile(u.Path) out, err := ioutil.ReadFile(u.Path)
if err != nil { if err != nil {
return s, errors.Wrap(err, "failed to read") return s, fmt.Errorf("failed to read: %w", err)
} }
template = string(out) template = string(out)