Skip to content

Commit a2072b4

Browse files
savely-krasovskyKrasovskiy Saveliy Igorevich
and
Krasovskiy Saveliy Igorevich
authored
feat: update Go version and dependencies (#111)
* 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 <[email protected]>
1 parent 962d573 commit a2072b4

9 files changed

+31
-1207
lines changed

.github/workflows/go.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go
1717
uses: actions/setup-go@v2
1818
with:
19-
go-version: 1.17
19+
go-version: 1.22
2020

2121
- name: Build w/ CGO
2222
run: GOOS=linux go build
@@ -43,4 +43,4 @@ jobs:
4343
run: go test -race -v ./...
4444

4545
- name: Test race w/o CGO
46-
run: go test -tags=ecies_test_race -race -v ./...
46+
run: go test -tags=ecies_test_race -race -v ./...

LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Weiliang Li
3+
Copyright (c) 2024 Weiliang Li
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This is the Go version of [ecies/py](https://github.com/ecies/py) with a built-i
1111
## Install
1212
`go get github.com/ecies/go/v2`
1313

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

1616
> ⚠️ Please use version 2.0.3 and later. It's much faster and safer.
1717
@@ -64,4 +64,4 @@ pkg: github.com/ecies/go/v2
6464
cpu: AMD Ryzen 7 5700G with Radeon Graphics
6565
BenchmarkEncrypt-16 10000 112632 ns/op 5655 B/op 68 allocs/op
6666
BenchmarkDecrypt-16 14038 85641 ns/op 4725 B/op 56 allocs/op
67-
```
67+
```

ecies_test.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"crypto/sha256"
55
"encoding/hex"
66
"io"
7-
"io/ioutil"
87
"math/big"
98
"net/http"
109
"net/url"
@@ -140,13 +139,15 @@ func TestDecryptAgainstPythonVersion(t *testing.T) {
140139
return
141140
}
142141

143-
defer resp.Body.Close()
142+
defer func() {
143+
_ = resp.Body.Close()
144+
}()
144145

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

149-
hexBytes, err := ioutil.ReadAll(resp.Body)
150+
hexBytes, err := io.ReadAll(resp.Body)
150151
if !assert.NoError(t, err) {
151152
return
152153
}
@@ -184,13 +185,15 @@ func TestEncryptAgainstPythonVersion(t *testing.T) {
184185
return
185186
}
186187

187-
defer resp.Body.Close()
188+
defer func() {
189+
_ = resp.Body.Close()
190+
}()
188191

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

193-
plaintext, err := ioutil.ReadAll(resp.Body)
196+
plaintext, err := io.ReadAll(resp.Body)
194197
if !assert.NoError(t, err) {
195198
return
196199
}

go.mod

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@ module github.com/ecies/go/v2
22

33
require (
44
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
5-
github.com/ethereum/go-ethereum v1.13.15
5+
github.com/ethereum/go-ethereum v1.14.12
66
github.com/stretchr/testify v1.10.0
77
golang.org/x/crypto v0.31.0
88
)
99

10-
go 1.13
10+
require (
11+
github.com/davecgh/go-spew v1.1.1 // indirect
12+
github.com/pmezard/go-difflib v1.0.0 // indirect
13+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
14+
gopkg.in/yaml.v3 v3.0.1 // indirect
15+
)
16+
17+
go 1.22
18+
19+
toolchain go1.23.3

go.sum

+2-1,191
Large diffs are not rendered by default.

privatekey_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package eciesgo
22

33
import (
44
"crypto/subtle"
5-
"github.com/stretchr/testify/assert"
65
"testing"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
const privkeyBase = "f0e5b2c3ba4df3fdb3ecea30d0e60c4e4a31d1ba928f51783ae18bbd3cada572"

publickey_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package eciesgo
22

33
import (
4-
"github.com/stretchr/testify/assert"
54
"testing"
5+
6+
"github.com/stretchr/testify/assert"
67
)
78

89
func TestNewPublicKeyFromHex(t *testing.T) {

secp256k1_cgo.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build cgo && !ecies_test_race
2-
// +build cgo,!ecies_test_race
32

43
package eciesgo
54

0 commit comments

Comments
 (0)