I am working on a new project using Go, and we are all new to Go. We are following the standard go directory structure, and having all code under
which is also the root of a git repository
/ doc/ src/ server/ main.go module1/ module.go client/ index.html Makefile
But is it actually necessary to have the code placed inside the GOPATH?
As an attempt I created a small program where the source code was outside the GOPATH. I could easily split the project into packages, so the
main package could reference a
foo package in a
foo/ folder using
As far as I can see, there are two things this disallows me:
- Other code cannot import this code. This is not a problem as we are building a service specifically for the company.
- I cannot use
go installto install it. This is not a problem either. The build pipeline installs the tool.
It does however allow the build server to not have its workspace be located inside the GOPATH
Is such an approach discouraged? If so, why so?
Are there other negative side effects than the two I have listed?
Bear in mind that this is a private project for a company, not public open source code.
Detaching the actual project from the GOPATH seems tempting, but one should be careful in breaking the rules when you are on the Shu stage