英文:
Golang failes to change the name of imported module
问题
我正在尝试将SkyDNSv1恢复并从我的分支构建它(这是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:
但是,如果你查看引起此错误的文件,你会注意到Golang对influxdb/client
感到困惑。我认为编译器没有将导入的名称client
替换为应该替换的influxClient
:
package influxdb
import (
"fmt"
influxClient "github.com/influxdb/influxdb/client"
"github.com/rcrowley/go-metrics"
"log"
"time"
)
可能我只是忽略了一个明显的错误。任何帮助将不胜感激。
英文:
I'm trying to bring SkyDNSv1 back to life and build it from my fork (here is Dockerfile). SkyDNS was really good and simple tool for the quick service discovery, but it wasn't updated for a long time.
There is an error in build process and it's caused by third party library. I cannot figure out why does it happen:
$ 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:
But if you look through the file causing this error, you'll notice that Golang is confused about influxdb/client
. I think that compiler doesn't replace imported name client
with influxClient
as it should do:
package influxdb
import (
"fmt"
influxClient "github.com/influxdb/influxdb/client"
"github.com/rcrowley/go-metrics"
"log"
"time"
)
Probably I just missing an obvious mistake. Any help will be appreciated.
答案1
得分: 3
Go编译器不会替换或重写任何内容,代码只是错误的。github.com/rcrowley/go-metrics/influxdb
包是使用一些已经不存在的influxdb客户端代码编写的。(看起来已经有几个github问题与此有关)
如果你查看当前的influxdb/client包,你会发现根本没有Series
、ClientConfig
或Client.WriteSeries
。为了使你的项目能够构建,你需要删除对github.com/rcrowley/go-metrics/influxdb
的依赖。
英文:
The Go compiler doesn't replace or rewrite anything, the code is just wrong. The github.com/rcrowley/go-metrics/influxdb
package was written with some other influxdb client code that no longer exists. (Looks like there are a couple github issues open about this already)
If you look at the current influxdb/client package, you'll see there's no Series
, ClientConfig
, or Client.WriteSeries
at all. You'll need to drop the dependency on github.com/rcrowley/go-metrics/influxdb
in order to get your project to build.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论