The error is correct. He tells you everything Gopher wants.
I am going to assume that you copied Gorilla Mux to the directory of your application / provider on your local computer, for example:
./main.go
If you want to know more about the provider, see my popular answer here:
How to use a provider in Go 1.6?
Now, to fix this error, assuming you did it above ...
Before you can build, Gopher must install a valid $GOPATH . This is not in your Docker file.
FROM golang:1.7-alpine EXPOSE 8080
Here he works ...
$ tree . ├── Dockerfile ├── main.go └── vendor └── mydep └── runme.go
Source file of my application:
$ cat main.go package main import ( "fmt" "mydep" ) func main() { fmt.Println(mydep.RunMe()) }
My dependency in my vendor/ folder:
$ cat vendor/mydep/runme.go package mydep // RunMe returns a string that it worked! func RunMe() string { return "Dependency Worked!" }
Now create and run the image:
$ docker build --rm -t test . && docker run --rm -it test (snip) Step 8 : WORKDIR $GOPATH/src/app ---> Using cache ---> 954ed8e87ae0 Step 9 : RUN go build -o myapp . ---> Using cache ---> b4b613f0a939 Step 10 : CMD /go/src/app/myapp ---> Using cache ---> 3524025080df Successfully built 3524025080df Dependency Worked!
Pay attention to the last line that displays the result from the console, Dependency Worked! .
This works because:
- You stated that you are using Vendoring, which means that you have a local directory named
./vendor in the root code of your application. - when you
ADD . /go/src/app ADD . /go/src/app , you will also copy the local ./vendor application code. - you copied your files to the correct
$GOPATH configuration structure needed by the Go build tools to find the packages (in this case, the ./vendor directory in the root folder of the source code).
source share