Building Go Projects with Private Repository Dependencies

In this example, you will use Cloud Native Build (CNB) to implement "go-private-repo-server" as a private Go repository dependency.
- Use Cloud Native Build (CNB) to build your project
- Write a Dockerfile
- Declarative build cache
- Understand environment variables and their usage
- Learn how to use Docker Artifact Repository
Key Points for Building Private Repository Dependencies in CNB
- Configure pipeline with GOPRIVATE and GONOSUMDB environment variables
- Configure git credentials:
git config --global url."https://${CNB_TOKEN_USER_NAME}:${CNB_TOKEN}@cnb.cool".insteadOf "https://cnb.cool"
Key Points for Local Development with Private Repository Dependencies
- Add these environment variables to your .bashrc or .zshrc:
export GOPRIVATE=e.coding.net,cnb.cool
export GONOSUMDB=e.coding.net,cnb.cool
- Configure .netrc with your CNB personal token:
machine cnb.cool
login cnb
password xxxxxxxx