Given I have some experience working with docker containers I decided to use docker containers to have a go environment and learn. Below is my dockerfile for go web app.
FROM golang:1.12.0-alpine3.9 as base
ARG GO111MODULE=on
RUN apk update && apk add make bash git
COPY ./app /go/src/app
WORKDIR /go/src/app
RUN go build
COPY ./compose/local/golang/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
RUN go get github.com/oxequa/realize
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["realize", "start"]
My go.mod file
module github.com/rajeshyogeshwar/demoapp
go 1.12
require (
github.com/Sirupsen/logrus v1.0.6
github.com/joho/godotenv v1.3.0
github.com/julienschmidt/httprouter v1.2.0
github.com/lib/pq v1.0.0
github.com/spf13/cobra v0.0.3
github.com/spf13/viper v1.2.0
)
and finally my project folder structure
As we can see I am trying to use httprouter module and it has been defined in my go.mod file. But I keep getting following error.
app_1 | [06:46:56][APP] : Install
app_1 | main.go:8:2: cannot find package "github.com/julienschmidt/httprouter" in any of:
app_1 | /usr/local/go/src/github.com/julienschmidt/httprouter (from $GOROOT)
app_1 | /go/src/github.com/julienschmidt/httprouter (from $GOPATH)
So if anyone can point out the obvious mistake it would be great.