From 275f8710b29cefa13b43b28e9bad6e0c92e5ad62 Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Thu, 30 May 2024 16:41:50 +0200 Subject: [PATCH 1/3] Use std lib errors --- cmd/localesdump/main.go | 3 +-- go.mod | 5 +---- go.sum | 2 -- localedata/database.go | 5 ++--- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/cmd/localesdump/main.go b/cmd/localesdump/main.go index 8db9f77..2d11f39 100644 --- a/cmd/localesdump/main.go +++ b/cmd/localesdump/main.go @@ -11,7 +11,6 @@ import ( "github.com/nyaruka/go-locales" "github.com/nyaruka/go-locales/localedata" - "github.com/pkg/errors" ) // matches locale codes in the form xx_YY or xxx_YY @@ -89,7 +88,7 @@ func extractData(mappings map[string]string) (map[string]localeDump, error) { ops, err := locales.Query(code, localedata.LC(category), keyword) if err != nil { - return nil, errors.Wrapf(err, "error querying path %s", path) + return nil, fmt.Errorf("error querying path %s: %w", path, err) } locale[key] = ops diff --git a/go.mod b/go.mod index 2c045de..30d739a 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,7 @@ module github.com/nyaruka/go-locales go 1.19 -require ( - github.com/pkg/errors v0.9.1 - github.com/stretchr/testify v1.8.4 -) +require github.com/stretchr/testify v1.8.4 require ( github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/go.sum b/go.sum index 57d96e6..fa4b6e6 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.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/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= diff --git a/localedata/database.go b/localedata/database.go index 1df1e9d..90fc0d1 100644 --- a/localedata/database.go +++ b/localedata/database.go @@ -7,7 +7,6 @@ import ( "strconv" "github.com/nyaruka/go-locales/fdcc" - "github.com/pkg/errors" ) // from https://sourceware.org/git/?p=glibc.git;a=tree;f=localedata/locales @@ -73,7 +72,7 @@ func LoadDatabase() (*Database, error) { file, err := static.Open(fmt.Sprintf("locales/%s", code)) if err != nil { - return nil, errors.Wrapf(err, "unable to open file %s", code) + return nil, fmt.Errorf("unable to open file %s: %w", code, err) } defer file.Close() @@ -82,7 +81,7 @@ func LoadDatabase() (*Database, error) { set, err := p.Parse() if err != nil { - return nil, errors.Wrapf(err, "unable to parse file %s", code) + return nil, fmt.Errorf("unable to parse file %s: %w", code, err) } locales[code] = newLocale(set) From 974a9fb3015f0244ac10b5f0ce0389e780801d1e Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Thu, 30 May 2024 17:00:30 +0200 Subject: [PATCH 2/3] Update Github actions to latest versions --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7feece..e3f227b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,14 +5,14 @@ jobs: name: Test strategy: matrix: - go-version: [1.19.x] + go-version: [1.22.x] runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Install Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} @@ -21,6 +21,6 @@ jobs: - name: Upload coverage if: success() - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 with: fail_ci_if_error: true From ee600c63b59d120cb9c4b680ca00efe5106ec270 Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Thu, 30 May 2024 18:01:19 +0200 Subject: [PATCH 3/3] Test on multiple go versions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3f227b..b7d2498 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ jobs: name: Test strategy: matrix: - go-version: [1.22.x] + go-version: [1.20.x, 1.21.x, 1.22.x] runs-on: ubuntu-latest steps: - name: Checkout code