Skip to content

Commit

Permalink
Update Go to 1.20 + bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
orlangure committed Feb 25, 2023
1 parent 5356544 commit 4f346d5
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ commands:
name: install golang
command: |
sudo rm -rf /usr/local/go
wget -c https://dl.google.com/go/go1.19.1.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
wget -c https://dl.google.com/go/go1.20.1.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
- checkout
- run:
name: Get dependencies
Expand Down
74 changes: 37 additions & 37 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
name: "[core] lint"
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
run: go get -v -t -d ./...
- name: Get golangci-lint
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.49.0
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.51.2
- name: Lint
run: $(go env GOPATH)/bin/golangci-lint run --timeout 10m0s ./...

Expand All @@ -32,10 +32,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand Down Expand Up @@ -111,10 +111,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -134,10 +134,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -157,10 +157,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -180,10 +180,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -203,10 +203,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -226,10 +226,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -249,10 +249,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -272,10 +272,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -295,10 +295,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -318,10 +318,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -341,10 +341,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -364,10 +364,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -387,10 +387,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -410,10 +410,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -433,10 +433,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand All @@ -456,10 +456,10 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
Expand Down
2 changes: 1 addition & 1 deletion cmd/cleaner/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/orlangure/gnomock/cmd/cleaner

go 1.19
go 1.20

require github.com/orlangure/gnomock v0.24.0

Expand Down
21 changes: 14 additions & 7 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gnomock

import (
"context"
"errors"
"fmt"
"io"
"net/url"
Expand All @@ -21,13 +22,12 @@ import (
"github.com/docker/go-connections/nat"
"github.com/orlangure/gnomock/internal/cleaner"
"github.com/orlangure/gnomock/internal/health"
"github.com/pkg/errors"
"go.uber.org/zap"
)

const (
localhostAddr = "127.0.0.1"
defaultStopTimeout = time.Second * 1
defaultStopTimeoutSec = 1
duplicateContainerPattern = `Conflict. The container name "(?:.+?)" is already in use by container "(\w+)". You have to remove \(or rename\) that container to be able to reuse that name.` // nolint:lll
dockerSockAddr = "/var/run/docker.sock"
)
Expand Down Expand Up @@ -55,7 +55,7 @@ func (g *g) dockerConnect() (*docker, error) {

cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
return nil, fmt.Errorf("%w: %s", ErrEnvClient, err)
return nil, errors.Join(ErrEnvClient, err)
}

g.log.Info("connected to docker engine")
Expand Down Expand Up @@ -193,7 +193,7 @@ func (d *docker) prepareContainer(
image string,
ports NamedPorts,
cfg *Options,
) (*container.ContainerCreateCreatedBody, error) {
) (*container.CreateResponse, error) {
pullImage := true

if cfg.UseLocalImagesFirst {
Expand Down Expand Up @@ -296,7 +296,12 @@ func (d *docker) portBindings(exposedPorts nat.PortSet, ports NamedPorts) nat.Po
return portBindings
}

func (d *docker) createContainer(ctx context.Context, image string, ports NamedPorts, cfg *Options) (*container.ContainerCreateCreatedBody, error) { // nolint:lll
func (d *docker) createContainer(
ctx context.Context,
image string,
ports NamedPorts,
cfg *Options,
) (*container.CreateResponse, error) {
exposedPorts := d.exposedPorts(ports)
containerConfig := &container.Config{
Image: image,
Expand Down Expand Up @@ -431,9 +436,11 @@ func (d *docker) stopContainer(ctx context.Context, id string) error {
d.lock.Lock()
defer d.lock.Unlock()

stopTimeout := defaultStopTimeout
stopTimeout := defaultStopTimeoutSec

err := d.client.ContainerStop(ctx, id, &stopTimeout)
err := d.client.ContainerStop(ctx, id, container.StopOptions{
Timeout: &stopTimeout,
})
if err != nil && !client.IsErrNotFound(err) {
return fmt.Errorf("can't stop container %s: %w", id, err)
}
Expand Down
16 changes: 7 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/orlangure/gnomock

go 1.19
go 1.20

require (
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/aws/aws-sdk-go v1.44.184
github.com/bradfitz/gomemcache v0.0.0-20221031212613-62deef7fc822
github.com/aws/aws-sdk-go v1.44.208
github.com/bradfitz/gomemcache v0.0.0-20230124162541-5f7a7d875746
github.com/denisenkom/go-mssqldb v0.12.3
github.com/docker/docker v20.10.23+incompatible
github.com/docker/docker v23.0.1+incompatible
github.com/docker/go-connections v0.4.0
github.com/elastic/go-elasticsearch/v7 v7.17.7
github.com/go-redis/redis v6.15.9+incompatible
Expand All @@ -18,14 +18,15 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/influxdata/influxdb-client-go/v2 v2.12.1
github.com/influxdata/influxdb-client-go/v2 v2.12.2
github.com/lib/pq v1.10.7
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/pkg/errors v0.9.1
github.com/segmentio/kafka-go v0.4.38
github.com/streadway/amqp v1.0.0
github.com/stretchr/testify v1.8.1
go.mongodb.org/mongo-driver v1.11.1
go.mongodb.org/mongo-driver v1.11.2
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.24.0
golang.org/x/sync v0.1.0
Expand Down Expand Up @@ -66,11 +67,8 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
Expand Down
Loading

0 comments on commit 4f346d5

Please # to comment.