【问题标题】:testcontainers-go: p.client.DaemonHost undefinedtestcontainers-go: p.client.DaemonHost 未定义
【发布时间】:2022-03-29 22:45:40
【问题描述】:

我正在尝试将 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)

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

【问题讨论】:

    标签: docker go integration-testing glide-golang testcontainers


    【解决方案1】:

    您是否尝试过使用 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)

    【讨论】:

      猜你喜欢
      • 2013-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-28
      • 2018-02-27
      • 1970-01-01
      • 2014-09-06
      相关资源
      最近更新 更多