Leveraging Nexus when Building a Golang Application
For this example, I’m creating a very simple Golang app
package main
import (
"github.com/beego/beego/v2/server/web"
)
func main() {
web.Router("/", &MainController{})
web.Run()
}
type MainController struct {
web.Controller
}
func (c *MainController) Get() {
response := map[string]string{
"message": "Hello World Beego",
"status": "success",
}
c.Data["json"] = response
c.ServeJSON()
}
And here’s the required go.mod file:
module hello-beego go 1.24.7 require github.com/beego/beego/v2 v2.3.8
Next, we’ll set up our Nexus to store the required Golang libraries. First, we start by creating a repository named go-proxy. The remote storage location for this repository will be proxy.golang.org.

We also need to point our Golang build proxy to the Nexus repository by exporting the GOPROXY variable.
$ export GOPROXY= http://localhost:8081/repository/go-proxy/
For more detailed logs, we can pull all our libraries using the following command:
$ GODEBUG=mod=1,gocacheverify=1 go mod tidy -v -x
This will show whether we’re able to pull libraries from the Nexus repository. We can also see the libraries that are being pulled in our Nexus repository.

By following above steps, we can successfully leverage Nexus to manage our Golang dependencies, ensuring a more efficient and controlled build environment.








