Search code examples
godockerskydns

Golang failes to change the name of imported module


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.


Solution

  • 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.