drau89457 2017-02-08 06:52
浏览 34

收到以下错误

I am recieving an error while compilation.

Root cause is the file has import of context package, but however during compilation github.com/docker/docker/vendor/golang.org/x/net/context is getting referred a, any pointers on as how to make it to refer to context import instead of docker's vendor package

Summarizing the issue, import in the file is as follows

import "golang.org/x/net/context"

there is a method call which takes context object as an argument, however, there are two repositories which have context ,

  • golang.org/x/net/context
  • github.com/docker/docker/vendor/golang.org/x/net/context

During compilation based on length go is selecting the 2 repository. But method needs the 1st one golang.org/x/net/context. hence the type error in code snippet is recieved

    "-X main.version=dev-49-gc8cc01b -X main.commit=c8cc01b -X     main.branch=master" ./...
 github.com/influxdata/telegraf/plugins/inputs/docker
 plugins/inputs/docker/docker.go:103: cannot use c (type *client.Client) as     type DockerClient in assignment:
    *client.Client does not implement DockerClient (wrong type for  ContainerList method)
            have ContainerList("github.com/docker/docker/vendor/golang.org/x/net/context".Context, types.ContainerListOptions) ([]types.Container, error)
            want ContainerList("context".Context, types.ContainerListOptions) ([]types.Container, error) make: *** [build] Error 2  sh-4.2# vi plugins/inputs/docker/docker.go
  • 写回答

1条回答 默认 最新

  • dongwai4434 2017-02-08 09:43
    关注

    Two options I can think of:

    1. Add an alias for the context import, e.g.

      goContext golang.org/x/net/context docContext github.com/docker/docker/vendor/golang.org/x/net/context

    2. Break the context dependencies into two files, or packages

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大