Skip to content

Commit

Permalink
feat: update Go version and dependencies (#111)
Browse files Browse the repository at this point in the history
* feat: update Go version and dependencies

Updated Go version requirement to 1.22 in `README.md` and `go.mod`. Also added missing indirect dependencies and updated Ethereum dependency version in `go.mod`.

* fix: update Go version in CI workflow to 1.22

* feat: modernize tests and update metadata

Reordered imports in test files and replaced ioutil.ReadAll with io.ReadAll for compatibility with modern Go standards. Improved error handling in defer statements for better clarity. Updated copyright year in LICENSE and cleaned up an obsolete build tag in secp256k1_cgo.go.

---------

Co-authored-by: Krasovskiy Saveliy Igorevich <skrasovskiy@ozon.ru>
  • Loading branch information
savely-krasovsky and Krasovskiy Saveliy Igorevich authored Dec 12, 2024
1 parent 962d573 commit a2072b4
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 1,207 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.22

- name: Build w/ CGO
run: GOOS=linux go build
Expand All @@ -43,4 +43,4 @@ jobs:
run: go test -race -v ./...

- name: Test race w/o CGO
run: go test -tags=ecies_test_race -race -v ./...
run: go test -tags=ecies_test_race -race -v ./...
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Weiliang Li
Copyright (c) 2024 Weiliang Li

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is the Go version of [ecies/py](https://github.com/ecies/py) with a built-i
## Install
`go get github.com/ecies/go/v2`

Go 1.13 is required cause `fmt.Errorf` is used to wrap errors.
Go 1.22 is required since 2.0.10.

> ⚠️ Please use version 2.0.3 and later. It's much faster and safer.
Expand Down Expand Up @@ -64,4 +64,4 @@ pkg: github.com/ecies/go/v2
cpu: AMD Ryzen 7 5700G with Radeon Graphics
BenchmarkEncrypt-16 10000 112632 ns/op 5655 B/op 68 allocs/op
BenchmarkDecrypt-16 14038 85641 ns/op 4725 B/op 56 allocs/op
```
```
13 changes: 8 additions & 5 deletions ecies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/sha256"
"encoding/hex"
"io"
"io/ioutil"
"math/big"
"net/http"
"net/url"
Expand Down Expand Up @@ -140,13 +139,15 @@ func TestDecryptAgainstPythonVersion(t *testing.T) {
return
}

defer resp.Body.Close()
defer func() {
_ = resp.Body.Close()
}()

if !assert.Equal(t, http.StatusCreated, resp.StatusCode) {
return
}

hexBytes, err := ioutil.ReadAll(resp.Body)
hexBytes, err := io.ReadAll(resp.Body)
if !assert.NoError(t, err) {
return
}
Expand Down Expand Up @@ -184,13 +185,15 @@ func TestEncryptAgainstPythonVersion(t *testing.T) {
return
}

defer resp.Body.Close()
defer func() {
_ = resp.Body.Close()
}()

if !assert.Equal(t, http.StatusCreated, resp.StatusCode) {
return
}

plaintext, err := ioutil.ReadAll(resp.Body)
plaintext, err := io.ReadAll(resp.Body)
if !assert.NoError(t, err) {
return
}
Expand Down
13 changes: 11 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ module github.com/ecies/go/v2

require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/ethereum/go-ethereum v1.13.15
github.com/ethereum/go-ethereum v1.14.12
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.31.0
)

go 1.13
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

go 1.22

toolchain go1.23.3
1,193 changes: 2 additions & 1,191 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion privatekey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package eciesgo

import (
"crypto/subtle"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

const privkeyBase = "f0e5b2c3ba4df3fdb3ecea30d0e60c4e4a31d1ba928f51783ae18bbd3cada572"
Expand Down
3 changes: 2 additions & 1 deletion publickey_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package eciesgo

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestNewPublicKeyFromHex(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion secp256k1_cgo.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build cgo && !ecies_test_race
// +build cgo,!ecies_test_race

package eciesgo

Expand Down

0 comments on commit a2072b4

Please sign in to comment.