golang多个子项目可以使用工作空间(workspace)组织在一起。
介绍
将多个子项目组成一个工作空间,解决相互依赖的问题。
使用
go 1.8(包括)之后的版本
help
Usage:
go work <command> [arguments]
The commands are:
edit edit go.work from tools or scripts
init initialize workspace file
sync sync workspace build list to modules
use add modules to workspace file
demo
go work init
mkdir subproj1
cd subproj1
go mod init subproj1
cd ..
go work use ./subproj1
$ cat go.work
go 1.19
use ./subproj1
gotip
go 1.8 之前版本
# install
go install golang.org/dl/gotip@latest
gotip download dev.cmdgo
# create go.work
gotip mod initwork subproj1 subproj2 ...
# build
gotip build <path-to-cmd>