My main.go file's path: /gowork/src/dockerpkgmain/main.go
my package file's path: /gowork/src/dockerpkg/mult/mult.go
my docker files path: /gowork/src/dockerpkgmain/Dockerfile
main.go:
package main
import (
"dockerpkg/mult"
"fmt"
)
func main() {
fmt.Println("From different pkg")
mult.Multiple()
}
mult.go:
package mult
import (
"flag"
"fmt"
)
func Multiple() {
first := flag.Int("f", 0, "placeholder")
second := flag.Int("s", 0, "placeholder")
flag.Parse()
out := (*first) * (*second)
fmt.Println(out)
}
Dockerfile:
FROM golang:1.9.1
COPY . /go/src/dockerpkg/mult
WORKDIR /go/src/app
COPY . .
ADD . /go/src/dockerpkg/mult
RUN go get -d -v ./...
RUN go install -v ./...
CMD ["app"]
ENTRYPOINT ["app", "-f=7", "-s=9"]
If I try
COPY . /go/src/dockerpkg/mult
I got this:
main.go:4:2: import "dockerpkg/mult" is a program, not an importable package
What must I put in my dockerfile to build my image without changing project structure?