go workspaces初探,个人感觉主要是为了方便本地开发工具包

1mkdir workspaces 
2cd workspaces
3mkdir fashnv lovep
4cd fashnv 
5go mod init github.com/cr-mao/fashnv
6cd ../lovep
7go mod init github.com/cr-mao/lovep
 1➜  workspaces tree                      
 2.
 3├── fashnv
 4│   ├── go.mod
 5│   ├── main
 6│   └── main.go
 7├── go.work
 8└── lovep
 9    ├── go.mod
10    └── tool.go
11
122 directories, 6 files
1cd workspaces 
2go work init 
3go work use ./fashnv
4go work use ./lovep

fashnv/main.go

 1package main
 2
 3import (
 4	"fmt"
 5	"github.com/cr-mao/lovep"
 6)
 7
 8func main() {
 9	fmt.Println("hello")
10	lovep.TempTool()
11}

lovep/tool.go

1package lovep
2
3import "fmt"
4
5func TempTool() {
6	fmt.Println("lovep")
7}
1cd lovep
2go run main.go 

结果

1hello
2lovep
1go build 
2
3go work sync # 同步依赖
4# 可能私有包 ,要加环境变量GOPRIVATE  待测试下