Depending on your target architecture, you may wish to build your Go binaries with Docker to maintain a reproducible build, limit your build size, and minimize the attack vectors for your service. Using multistage Docker builds can help us to accomplish this task.
To perform these actions, you must have a recent version of Docker installed. The multistage builds feature that we are going to use requires Docker version 17.05 or higher in both the daemon and the client. You can find the most recent version of Docker for your OS, as well as instructions on how to install it, at https://docs.docker.com/install/.
Consider the following simple package that logs a debug message to the screen:
package main
import "go.uber.org/zap"
func main() {
zapLogger: = zap.NewExample()
defer zapLogger.Sync()
zapLogger.Debug("Hi Gophers - from our Zap...