go-zero
go-zero copied to clipboard
feat(goctl): support go work (#4332)
this PR fixed the error no matched module
when using goctl api
inside of a go workspace.
in go workspace, command go list -m -f '{{.GoMod}}'
only lists modules declared in go.work, so goctl can't can the go.mod path even it's already initilized if the project is not in go.work.
to fix this, goctl should
- use
go env GOMOD
to determine whether the project is a go module. - check if the project is inside of a go workspace, if it does, it will use
go work use .
to add the project to go.work.