How to add Build time env var through doctl in a Functions namespace

I’ve recently started working with “Functions” service in Golang. As I understand, I need a namespace to test it out with doctl, and it seems to me that it is totally different than App Platform.

Now a need to use a private Go module from GitHub has arised, and I found out from this and this documentation that I need to set a GO_GIT_CRED__HTTPS__GITHUB__COM build time env var. I know I can do it in App Platform, but I need to do the same in a namespace, so that I can test it out locally using doctl and push it to the Production App Platform.

So far I have tried to add the above env var into project.yml but it seems unfruitful. I get the following:

go mod download: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/go/pkg/mod/cache/vcs/642ca7a2cf3bf96e7ac2e10395c4ae76f4d7bb66b0d13784004f523d66c63b37: exit status 128:
        fatal: could not read Username for '': terminal prompts disabled

Note: I’ve tried the username:pat syntax for GO_GIT_CRED__HTTPS__GITHUB__COM and yet it results in the same above error.

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Greg M
DigitalOcean Employee
DigitalOcean Employee badge
December 19, 2022

Hey @CyberCitizen01, can you try adding that env var in a .env file (or similar) and passing the path to that file to the --build-env flag in doctl serverless deploy?


cat <<EOF > /path/to/serverless/repo/build.env

doctl serverless deploy /path/to/serverless/repo --build-env /path/to/serverless/repo/build.env