You may be put your golang modules in a self-hosting git repository which likes gitlab. The most ways to tell us using ssh method and it is not easy enough (need to generate ssh key). I am just want to use https to get golang modules.
FROM golang:1.13.4-alpine
...
...
...
ARG GIT_URL
ARG GIT_GROUP
ARG GIT_ACCOUNT
ARG GIT_PASSWORD
RUN apk update -qq && apk --no-cache add git
RUN printf "machine ${GIT_URL}\n\
login ${GIT_ACCOUNT}\n\
password ${GIT_PASSWORD}\n"\
>> /root/.netrc
RUN chmod 600 /root/.netrc
RUN go env -w GOPRIVATE=${GIT_URL}/${GIT_GROUP}
...
...
...