Skip to content

Undefined error for client.NewClientWithOpts in Go SDK #40185

@erbesharat

Description

@erbesharat

Description
Since the SDK documentation is a bit outdated I've no idea what version of SDK I should use and what are the correct methods to call that are not deprecated for creating a new client.

Am I using an incorrect version or have something cached on my machine which results in the errors mentioned below?
I think it's probably because of a cache issue which I get these errors.

Steps to reproduce the issue:

  1. Import github.com/docker/docker/client
  2. Call client.NewClientWithOpts()
  3. Get undefined: client.NewClientWithOpts error

Describe the results you received:
Here are the errors I got after running my code:

./main.go:107:14: undefined: client.NewClientWithOpts
./main.go:107:39: undefined: client.WithVersion
./main.go:305:40: too many arguments in call to d.cli.ContainerWait
./main.go:305:70: undefined: container.WaitConditionNotRunning
./main.go:307:14: invalid operation: <-errCh (receive from non-chan type error)
./main.go:311:17: invalid operation: <-statusCh (receive from non-chan type int64)

Describe the results you expected:
Client getting created successfully and waiting for the container to exit without any errors.

Additional information you deem important (e.g. issue happens only occasionally):
Here is my go.mod file:

module go.txtdirect.org/txtdirect/e2e

go 1.13

require (
	github.com/Microsoft/go-winio v0.4.14 // indirect
	github.com/docker/distribution v2.7.1+incompatible // indirect
	github.com/docker/docker v1.13.1-rc2
	github.com/docker/go-connections v0.4.0
	github.com/docker/go-units v0.4.0 // indirect
	github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
	github.com/stretchr/testify v1.4.0 // indirect
	golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271 // indirect
)

Here is the code that I wrote which produces the mentioned errors:
txtdirect/txtdirect#298

Output of docker version:

Client:
 Version:           18.09.7-ce
 API version:       1.39
 Go version:        go1.12.6
 Git commit:        2d0083d657
 Built:             Tue Jul  2 01:00:04 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.09.7-ce
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.12.6
  Git commit:       2d0083d657
  Built:            Tue Jul  2 00:59:35 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

Containers: 152
 Running: 0
 Paused: 0
 Stopped: 152
Images: 175
Server Version: 18.09.7-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: f80d2850797c8132e995bbaa14ff665db5a1d3aa.m
runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.20.17-1-MANJARO
Operating System: Manjaro Linux
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.496GiB
Name: valhalla
ID: PCMA:ODGK:KMID:ORL4:SROV:M77F:X6FJ:P6CQ:RCD7:NRFV:DLOZ:YMKA
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: erbesharat
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):
The code is running on my local environment. Let me know if I've to provide any other information.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions