In order to compile a fully static binary when using Cgo you'll need to link in a C library like musl.
I find it convenient to have a Docker image ready for building these artifacts.
FROM golang
RUN wget https://musl.libc.org/releases/musl-1.2.5.tar.gz && \
tar -xzf musl-1.2.5.tar.gz && \
cd musl-1.2.5 && \
./configure --enable-static --disable-shared && \
make && make install
Then to build your progam:
CGO_ENABLED=1 CC=/usr/local/musl/bin/musl-gcc go build --ldflags '-linkmode=external -extldflags=-static'
Command should be: