Skip to content

Commit

Permalink
go: bump go to 1.20
Browse files Browse the repository at this point in the history
Bump go version to 1.20.

Update ci to use go version 1.20 and newer.

Remove usage of the deprecated libraries.

Part of #378
  • Loading branch information
DerekBum authored and oleg-jukovec committed Feb 9, 2024
1 parent f33032e commit 49571b6
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/reusable_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Setup golang for connector and tests
uses: actions/setup-go@v2
with:
go-version: 1.13
go-version: '1.20'

- name: Setup tt
run: |
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
fail-fast: false
matrix:
golang:
- 1.13
- '1.20'
- 'stable'
tarantool:
- '1.10'
- '2.8'
Expand All @@ -40,10 +41,10 @@ jobs:
include:
- tarantool: 'master'
coveralls: true
golang: 1.13
golang: '1.20'
- tarantool: 'master'
fuzzing: true
golang: 1.18
golang: '1.20'
coveralls: false

steps:
Expand Down Expand Up @@ -132,7 +133,8 @@ jobs:
fail-fast: false
matrix:
golang:
- 1.13
- '1.20'
- 'stable'
runs-on:
- macos-11
- macos-12
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
`pool.Instance` to determinate connection options (#356)
- `pool.Connect`, `pool.ConnectWithOpts` and `pool.Add` add connections to
the pool even it is unable to connect to it (#372)
- Required Go version from `1.11` to `1.20` (#378)

### Deprecated

Expand Down
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ coverage:
.PHONY: coveralls
coveralls: coverage
go get github.com/mattn/goveralls
go install github.com/mattn/goveralls
goveralls -coverprofile=$(COVERAGE_FILE) -service=github

.PHONY: bench-deps
Expand All @@ -122,14 +123,9 @@ ${BENCH_PATH} bench-deps:
rm -rf ${BENCH_PATH}
mkdir ${BENCH_PATH}
go clean -testcache
# It is unable to build a latest version of benchstat with go 1.13. So
# we need to switch to an old commit.
cd ${BENCH_PATH} && \
git clone https://go.googlesource.com/perf && \
cd perf && \
git checkout 91a04616dc65ba76dbe9e5cf746b923b1402d303 && \
go install ./cmd/benchstat
rm -rf ${BENCH_PATH}/perf
go get golang.org/x/perf/cmd/benchstat
go install golang.org/x/perf/cmd/benchstat

.PHONY: bench
${BENCH_FILE} bench: ${BENCH_PATH}
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ faster than other packages according to public benchmarks.
We assume that you have Tarantool version 1.10+ and a modern Linux or BSD
operating system.

You need a current version of `go`, version 1.13 or later (use `go version` to
You need a current version of `go`, version 1.20 or later (use `go version` to
check the version number). Do not use `gccgo-go`.

**Note:** If your `go` version is older than 1.13 or if `go` is not installed,
**Note:** If your `go` version is older than 1.20 or if `go` is not installed,
download and run the latest tarball from [golang.org][golang-dl].

The package `go-tarantool` is located in [tarantool/go-tarantool][go-tarantool]
Expand All @@ -72,7 +72,7 @@ This allows us to introduce new features without losing backward compatibility.
```
go_tarantool_decimal_fuzzing
```
**Note:** It crashes old Tarantool versions and requires Go 1.18+.
**Note:** It crashes old Tarantool versions.

## Documentation

Expand Down Expand Up @@ -223,6 +223,10 @@ is only available in Tarantool Enterprise Edition 2.10 or newer.

The article describes migration from go-tarantool to go-tarantool/v2.

#### Go version

Required Go version is set to `1.20`.

#### datetime package

Now you need to use objects of the Datetime type instead of pointers to it. A
Expand Down
9 changes: 4 additions & 5 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ func (conn *Connection) eventer(events <-chan connWatchEvent) {
st := value.(chan watchState)
state := <-st
state.value = event.value
if state.version == math.MaxUint64 {
if state.version == math.MaxUint {
state.version = initWatchEventVersion + 1
} else {
state.version += 1
Expand Down Expand Up @@ -1277,9 +1277,8 @@ func (conn *Connection) NewStream() (*Stream, error) {
type watchState struct {
// value is a current value.
value interface{}
// version is a current version of the value. The only reason for uint64:
// go 1.13 has no math.Uint.
version uint64
// version is a current version of the value.
version uint
// ack true if the acknowledge is already sent.
ack bool
// cnt is a count of active watchers for the key.
Expand All @@ -1292,7 +1291,7 @@ type watchState struct {
}

// initWatchEventVersion is an initial version until no events from Tarantool.
const initWatchEventVersion uint64 = 0
const initWatchEventVersion uint = 0

// connWatcher is an internal implementation of the Watcher interface.
type connWatcher struct {
Expand Down
3 changes: 1 addition & 2 deletions future_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"errors"
"io"
"io/ioutil"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -74,7 +73,7 @@ func (resp *futureMockResponse) DecodeTyped(res interface{}) error {
}

func createFutureMockResponse(header Header, body io.Reader) (Response, error) {
data, err := ioutil.ReadAll(body)
data, err := io.ReadAll(body)
if err != nil {
return nil, err
}
Expand Down
9 changes: 8 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tarantool/go-tarantool/v2

go 1.11
go 1.20

require (
github.com/google/uuid v1.3.0
Expand All @@ -9,3 +9,10 @@ require (
github.com/tarantool/go-iproto v1.0.0
github.com/vmihailenco/msgpack/v5 v5.3.5
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
3 changes: 1 addition & 2 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package tarantool
import (
"fmt"
"io"
"io/ioutil"

"github.com/tarantool/go-iproto"
"github.com/vmihailenco/msgpack/v5"
Expand Down Expand Up @@ -39,7 +38,7 @@ func createBaseResponse(header Header, body io.Reader) (baseResponse, error) {
if buf, ok := body.(*smallBuf); ok {
return baseResponse{header: header, buf: *buf}, nil
}
data, err := ioutil.ReadAll(body)
data, err := io.ReadAll(body)
if err != nil {
return baseResponse{}, err
}
Expand Down
15 changes: 8 additions & 7 deletions test_helpers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -185,10 +184,7 @@ func StartTarantool(startOpts StartOpts) (TarantoolInstance, error) {
inst.Dialer = startOpts.Dialer

if startOpts.WorkDir == "" {
// Create work_dir for a new instance.
// TO DO: replace with `os.MkdirTemp` when we drop support of
// Go 1.16 an older
dir, err = ioutil.TempDir("", "work_dir")
dir, err = os.MkdirTemp("", "work_dir")
if err != nil {
return inst, err
}
Expand Down Expand Up @@ -305,7 +301,7 @@ func copySslCerts(dst string, sslCertsDir string) (err error) {
}

func copyDirectoryFiles(scrDir, dest string) error {
entries, err := ioutil.ReadDir(scrDir)
entries, err := os.ReadDir(scrDir)
if err != nil {
return err
}
Expand All @@ -324,7 +320,12 @@ func copyDirectoryFiles(scrDir, dest string) error {
return err
}

if err := os.Chmod(destPath, entry.Mode()); err != nil {
info, err := entry.Info()
if err != nil {
return err
}

if err := os.Chmod(destPath, info.Mode()); err != nil {
return err
}
}
Expand Down
3 changes: 1 addition & 2 deletions test_helpers/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package test_helpers
import (
"bytes"
"io"
"io/ioutil"
"testing"

"github.com/vmihailenco/msgpack/v5"
Expand Down Expand Up @@ -43,7 +42,7 @@ func CreateMockResponse(header tarantool.Header, body io.Reader) (*MockResponse,
if body == nil {
return &MockResponse{header: header, data: nil}, nil
}
data, err := ioutil.ReadAll(body)
data, err := io.ReadAll(body)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 49571b6

Please sign in to comment.