3

I am trying to add TestContainers-Go to my project. I use glide and TestNginxLatestReturn example from Github readme file.

In glide I put

- package: github.com/testcontainers/testcontainers-go
version: v0.0.3

but at runtime I get this error in IDEA.

# github.com/testcontainers/testcontainers-go
../../../../../../pkg/mod/github.com/testcontainers/testcontainers-go@v0.0.3/docker.go:326:32: p.client.DaemonHost undefined (type *client.Client has no field or method DaemonHost)

Any idea why I get this and how to fix it?

enter image description here

Nikolay Kuznetsov
  • 9,467
  • 12
  • 55
  • 101

1 Answers1

0

Have you tried with Go modules? I noticed glide's last commit is from 2'5 years ago, not sure if you're still using it.

With Go modules, it would be a matter of adding the dependency to your go.mod file. Something like this:

require (
    github.com/testcontainers/testcontainers-go v0.12.0
)

You can find more info about installing it in project's docs: https://golang.testcontainers.org/quickstart

Related to the current error with glide, it seems the Docker dependency in testcontainers-go v0.0.3 (docker/docker-v0.7.3) should include the client.DaemonHost method, which was added on 22 May 2017 in https://github.com/moby/moby/commit/6ce6ae1cd11d888e0c8ede20926b86981cee5ce1.

I recommend you using a newer version of the library (v0.12.0)

mdelapenya
  • 76
  • 3