Hi, I hope this is the right place to post this in case anyone knows the answer to what might be a simple question.
I’m a beginner with Go and Docker. I have written a simple webapp that connects to a MySQL PaaS on GCP. When I run the code locally it works fine. I would like to containerize the application and run it as a container.
I get the following error;
main.go:16:5: cannot find package “go-sql-driver/mysql” in any of:
** /usr/local/go/src/go-sql-driver/mysql (from $GOROOT)**
** /go/src/go-sql-driver/mysql (from $GOPATH)**
The command ‘/bin/sh -c CGO_ENABLED=0 go build -o /bin/demo’ returned a non-zero code: 1
For the following dockerfile
FROM golang:1.11-alpine AS build
COPY main.go /form/ /src/*
RUN apk update -qq && apk add git
RUN go get -d github.com/go-sql-driver/mysql
RUN CGO_ENABLED=0 go build -o /bin/demo
COPY --from=build /bin/demo /bin/demo
Thanks for any tips to stop me going mad!