Merge pull request #9 from donny-dont/remove-pkg-errors

Remove pkg/errors
This commit is contained in:
Brad Rydzewski 2020-09-22 13:28:14 -04:00 committed by GitHub
commit d25f0a0b9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
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

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/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=

View File

@ -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)