Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
feat: added go 1.17 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Taliesin Millhouse committed Aug 21, 2021
1 parent 3e85668 commit 843e97d
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .github/semtantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Configuration for Semantic Pull Requests
titleOnly: true

types:
- feat
- fix
- docs
- style
- refactor
- perf
- test
- build
- ci
- chore
- revert
- release
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ^1.16
go-version: ^1.17
- run: |
go get -v -t -d ./...
- run: |
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v0.5.0 - 2021-08-21
### Added
* Added Go 1.17 support.
* Added ```Wrapf``` function.

## v0.4.1 - 2021-08-07
### Fixed
* Fixed a string escaping bug in ```Error.MarshalJSON```.
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ enforcement ladder](https://github.com/mozilla/diversity).

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
https://www.contributor-covenant.org/translations.
5 changes: 5 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func Wrap(message string, err error) *Error {
}
}

// Wrap is a helper function to wrap another Error with formatting.
func Wrapf(message string, err error, args ...interface{}) * Error {
return Wrap(fmt.Sprintf(message, args...), err)
}

// Error implements the error interface to provide a formatted stack trace.
func (e *Error) Error() string {
if err, ok := e.Err.(*Error); ok {
Expand Down
15 changes: 15 additions & 0 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,18 @@ func TestWrap(t *testing.T) {

require.Equal(t, expected, xerror.Wrap("failed to do something", errors.New("the thing that failed")))
}

func TestWrapf(t *testing.T) {
workingDirectory, err := os.Getwd()
require.NoError(t, err)

expected := &xerror.Error{
Err: errors.New("the thing that failed"),
FunctionName: "github.com/gofor-little/xerror.Wrapf",
FileName: workingDirectory + "/error.go",
LineNumber: 52,
Message: "failed to do something: was this",
}

require.Equal(t, expected, xerror.Wrapf("failed to do something: %s", errors.New("the thing that failed"), "was this"))
}
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module github.com/gofor-little/xerror

go 1.16
go 1.17

require github.com/stretchr/testify v1.7.0

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)

0 comments on commit 843e97d

Please sign in to comment.