Use GOPATH in golang makefile or init go mod first?

912 Views Asked by At

I'm learning to write Golang makefile and got some confused me because some examples they config GO env such as GOOS, GOPATH, GOBASE before building. But normally I can use go mod init to create go module and in Makefile use go build to build my project. So what's is the best approach ?

1

There are 1 best solutions below

1
On

Modern go code with go mod. Makefile should not include GOPATH. Just use go build is enough.

see https://blog.golang.org/using-go-modules