docker - testcontainers-go : p. client.DaemonHost

我正在尝试将 TestContainers-Go 添加到我的项目中。我使用 Github 自述文件中的 glide 和 TestNginxLatestReturn 示例。

我在滑行中

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

但是在运行时,我在 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)

知道我为什么会遇到这个问题以及如何解决它吗?

最佳答案

您是否尝试过使用 Go 模块?我注意到 glide 的最后一次提交是 2'5 年前的,不确定你是否还在使用它。

对于 Go 模块,只需将依赖项添加到 go.mod 文件即可。像这样:

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

您可以在项目的文档中找到有关安装它的更多信息:https://golang.testcontainers.org/quickstart/gotest/#1-install

glide的当前错误相关,testcontainers-go v0.0.3 (docker/docker-v0.7.3) 中的 Docker 依赖项似乎应该包括 client.DaemonHost 方法,于 2017 年 5 月 22 日在 https://github.com/moby/moby/commit/6ce6ae1cd11d888e0c8ede20926b86981cee5ce1 中添加.

我建议您使用更新版本的库 (v0.12.0)

关于docker - testcontainers-go : p. client.DaemonHost 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55954363/

相关文章:

reactjs - VSCode 不会在 typescript 中导入 组件

amazon-web-services - CloudFormation 无法创建 CodeDepl

python - 基于 GDAL/OGR 的并行空间处理和使用 python 的空间过滤器?

go - context.TODO() 或 context.Background(),我更喜欢哪一个

sql - 从 SQL Server 到 Oracle 使用点表示法与 OpenQuery

azure - 如何在 Azure Devops 中为多模块 Maven 创建构建管道

continuous-integration - 如何在 1 个作业中定义 2 个具有不同 when

c# - 为什么 IServerStreamWriter 不发送通知响应?

express - 如何在 Google App Engine 中允许跨站点来源请求?

javascript - 如何将 javascript 文件从公用文件夹导入到 SRC 文件夹并使用