将Go项目的根目录更改为不是src

Ahoy,

We have a large monolithic repository with all our code in it. We have recently started to use Go, however, are having issues since most tooling for Go assumes that the root directory is src/ but ours is not. Our directory structure is based on product areas and not based on language or tooling. We don't want to have a separate directory just for Go.

How can we setup the Go path to not assume that the directory starts at src?

Thanks!

The safest course of action is to have two worktrees:

  • one for your current directory structure, based on product areas
  • one for Go development respecting GOPATH

Each time you will make a commit in the second worktree, you can git pull/update your first worktree to keep it up-to-date.