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
Thanks for the response. As it’s the first time I’ve done this, I think I need a hand getting this done in the dockerfile.
`FROM golang:1.11-alpine AS build
Doesn’t work. When I run the container I get this. C:\Users\sesa82231\Desktop\Ant\go\testapi>docker container run -p 8080:8080 testapi 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)