我正在尝试使SkyDNSv1复活,并从我的 fork 中构建它(这是Dockerfile)。 SkyDNS是用于快速发现服务的非常好的简单工具,但是很长一段时间没有更新。

生成过程中存在错误,这是由第三方库引起的。我不知道为什么会这样:

$ docker build --no-cache -t skydns1 .
Sending build context to Docker daemon 1.566 MB
Sending build context to Docker daemon
Step 0 : FROM golang:1.4.2
 ---> 3e8cb8e0c765
Step 1 : WORKDIR /go/src
 ---> Running in 3a06cf460ad9
 ---> 1dd14a099164
Removing intermediate container 3a06cf460ad9
Step 2 : RUN go get github.com/codegangsta/cli
 ---> Running in eabcfd6fe621
 ---> c9ea222f2d74
Removing intermediate container eabcfd6fe621
Step 3 : RUN go get github.com/vitalyisaev2/skydns1
 ---> Running in 3264582b2e7a
# github.com/rcrowley/go-metrics/influxdb
github.com/rcrowley/go-metrics/influxdb/influxdb.go:19: undefined: client.ClientConfig
github.com/rcrowley/go-metrics/influxdb/influxdb.go:38: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:44: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:52: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:60: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:70: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:82: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:93: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:106: client.WriteSeries undefined (type *client.Client has no field or method WriteSeries)
INFO[0075] The command [/bin/sh -c go get github.com/vitalyisaev2/skydns1] returned a non-zero code:

但是,如果您仔细查看导致此错误的file,您会发现Golang对influxdb/client感到困惑。 我认为编译器不会像应该那样将导入的名称client替换为influxClient:
package influxdb

import (
    "fmt"
    influxClient "github.com/influxdb/influxdb/client"
    "github.com/rcrowley/go-metrics"
    "log"
    "time"
)

可能我只是错过了一个明显的错误。任何帮助将不胜感激。

最佳答案

Go编译器不会替换或重写任何内容,代码只是错误的。 github.com/rcrowley/go-metrics/influxdb包是用不再存在的其他influxdb客户端代码编写的。 (看起来已经有一些关于此问题的github问题)

如果查看当前的influxdb/client包,您将看到根本没有SeriesClientConfigClient.WriteSeries。您需要删除对github.com/rcrowley/go-metrics/influxdb的依赖关系才能构建您的项目。

关于go - Golang无法更改导入模块的名称,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30922834/

10-16 23:59