go-zero
go-zero copied to clipboard
About goctl not working after upgrade
goctl upgrade after version: v1.7.2
run: goctl upgrade or go install github.com/zeromicro/go-zero/tools/goctl@latest
executing any goctl command will result in the following
goctl --version
[1] 36328 killed goctl --version
Later I had to switch back to the original version, and it worked immediately:
go install github.com/zeromicro/go-zero/tools/[email protected]
I guess you're using gvm?
Here are some detailed troubleshooting steps and potential solutions:
Possible causes and solutions:
-
Memory limits or architecture incompatibility:
- The
killedmessage typically indicates the process was terminated by the OS, often due to memory issues or a segmentation fault.
- The
-
GVM (Go Version Manager) conflicts:
- If you're using GVM, there might be conflicts with the Go environment settings.
- Try temporarily disabling GVM and installing with a standard Go installation.
-
Dependency conflicts:
- Try clearing the Go module cache and reinstalling:
go clean -modcache go install github.com/zeromicro/go-zero/tools/goctl@latest
- Try clearing the Go module cache and reinstalling:
-
Compatibility with your OS/architecture:
- What OS and architecture are you using? The latest version might have issues with specific platforms.
- Try building from source to see if it resolves the issue:
git clone https://github.com/zeromicro/go-zero.git cd go-zero/tools/goctl go build -o goctl main.go # Move the binary to your PATH
-
Check for core dumps:
- If your OS generates core dumps, check for them and submit them with your issue to help diagnose the problem.
- On macOS/Linux:
ulimit -c unlimitedbefore running goctl can enable core dumps.
-
Runtime environment:
- Try to capture the full environment when the crash occurs:
env | grep GO which goctl go version
- Try to capture the full environment when the crash occurs:
-
Pinning to a stable version:
- As a temporary workaround, you can pin to the last stable version while the issue is being investigated:
go install github.com/zeromicro/go-zero/tools/goctl@latest
- As a temporary workaround, you can pin to the last stable version while the issue is being investigated:
-
CGO related issues:
- Try disabling CGO to see if it helps:
CGO_ENABLED=0 go install github.com/zeromicro/go-zero/tools/goctl@latest
- Try disabling CGO to see if it helps:
@kevwan 最新版生成 types.go 文件存在问题,使用 v1.8.2 时是正常的 使用 v1.8.3 时报错
@kevwan 最新版生成 types.go 文件存在问题,使用 v1.8.2 时是正常的 使用 v1.8.3 时报错
export GOCTL_EXPERIMENTAL=off
设置了,没用,生成路径错误,types.go 正常应该生成的路径:app/demo/rest/internal/types/types.go ,v1.8.3 生成报如下错误:
goctl api go --api=app/demo/rest/demo.api --dir=app/demo/rest/
app/demo/rest/etc/demo-api.yaml exists, ignored generation app/demo/rest/internal/config/config.go exists, ignored generation app/demo/rest/demo.go exists, ignored generation app/demo/rest/internal/svc/servicecontext.go exists, ignored generation 2025/05/05 15:39:30 open app/demo/rest/internal/types/adminapi/demo/demo.go: no such file or directory
goroutine 1 [running]: runtime/debug.Stack() /opt/homebrew/Cellar/go/1.24.2/libexec/src/runtime/debug/stack.go:26 +0x64 github.com/zeromicro/go-zero/core/logx.Must({0x1019ac398?, 0x14000473b60?}) /Users/XiaoMing/Go/pkg/mod/github.com/zeromicro/[email protected]/core/logx/logs.go:268 +0x40 github.com/zeromicro/go-zero/tools/goctl/api/gogen.DoGenProject({0x14000122156, 0x1c}, {0x1400012c936, 0x11}, {0x101332bcd, 0x6}, 0x0) /Users/XiaoMing/Go/pkg/mod/github.com/zeromicro/go-zero/tools/[email protected]/api/gogen/gen.go:100 +0x148 github.com/zeromicro/go-zero/tools/goctl/api/gogen.GoCommand(0x14000148b00?, {0x1013304b6?, 0x4?, 0x1013303b6?}) /Users/XiaoMing/Go/pkg/mod/github.com/zeromicro/go-zero/tools/[email protected]/api/gogen/gen.go:71 +0x160 github.com/spf13/cobra.(*Command).execute(0x14000164308, {0x140002dd420, 0x2, 0x2}) /Users/XiaoMing/Go/pkg/mod/github.com/spf13/[email protected]/command.go:1015 +0x828 github.com/spf13/cobra.(*Command).ExecuteC(0x140000fa908) /Users/XiaoMing/Go/pkg/mod/github.com/spf13/[email protected]/command.go:1148 +0x350 github.com/spf13/cobra.(*Command).Execute(...) /Users/XiaoMing/Go/pkg/mod/github.com/spf13/[email protected]/command.go:1071 github.com/zeromicro/go-zero/tools/goctl/cmd.Execute() /Users/XiaoMing/Go/pkg/mod/github.com/zeromicro/go-zero/tools/[email protected]/cmd/root.go:47 +0x7c main.main() /Users/XiaoMing/Go/pkg/mod/github.com/zeromicro/go-zero/tools/[email protected]/goctl.go:12 +0x60
echo $GOCTL_EXPERIMENTAL
off
@kevwan 最新版生成 types.go 文件存在问题,使用 v1.8.2 时是正常的 使用 v1.8.3 时报错
export GOCTL_EXPERIMENTAL=off
not export GOCTL_EXPERIMENTAL=off, but goctl env -w GOCTL_EXPERIMENTAL=off
@kevwan 最新版生成 types.go 文件存在问题,使用 v1.8.2 时是正常的 使用 v1.8.3 时报错
export GOCTL_EXPERIMENTAL=off
not
export GOCTL_EXPERIMENTAL=off, butgoctl env -w GOCTL_EXPERIMENTAL=off
可行,可以用了
没设置时, 提示 no such file or directory 功能是不是还需要优化一下,没有目录自动创建对应目录
@Xiphin pls Add my wechat iikeson, let me reproduce this bug
方便加一下我的微信吗,微信号 iikeson, 我看一下你的 api 怎么定义的,我复现一下。
@Xiphin pls Add my wechat
iikeson, let me reproduce this bug方便加一下我的微信吗,微信号
iikeson, 我看一下你的 api 怎么定义的,我复现一下。
加你了 通过一下