Skip to content

About goctl not working after upgrade #4818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RanX12 opened this issue Apr 30, 2025 · 12 comments
Open

About goctl not working after upgrade #4818

RanX12 opened this issue Apr 30, 2025 · 12 comments
Labels
area/goctl Categorizes issue or PR as related to goctl.

Comments

@RanX12
Copy link

RanX12 commented Apr 30, 2025

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]

@kevwan
Copy link
Contributor

kevwan commented May 2, 2025

I guess you're using gvm?

@kevwan
Copy link
Contributor

kevwan commented May 2, 2025

Here are some detailed troubleshooting steps and potential solutions:

Possible causes and solutions:

  1. Memory limits or architecture incompatibility:

    • The killed message typically indicates the process was terminated by the OS, often due to memory issues or a segmentation fault.
  2. 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.
  3. Dependency conflicts:

    • Try clearing the Go module cache and reinstalling:
      go clean -modcache
      go install github.com/zeromicro/go-zero/tools/goctl@latest
  4. 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
  5. 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 unlimited before running goctl can enable core dumps.
  6. Runtime environment:

    • Try to capture the full environment when the crash occurs:
      env | grep GO
      which goctl
      go version
  7. 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
  8. CGO related issues:

    • Try disabling CGO to see if it helps:
      CGO_ENABLED=0 go install github.com/zeromicro/go-zero/tools/goctl@latest

@kevwan kevwan added bug area/goctl Categorizes issue or PR as related to goctl. and removed bug labels May 2, 2025
@Xiphin
Copy link

Xiphin commented May 5, 2025

@kevwan 最新版生成 types.go 文件存在问题,使用 v1.8.2 时是正常的 使用 v1.8.3 时报错

@voidint
Copy link
Contributor

voidint commented May 5, 2025

@kevwan 最新版生成 types.go 文件存在问题,使用 v1.8.2 时是正常的 使用 v1.8.3 时报错

export GOCTL_EXPERIMENTAL=off

@Xiphin
Copy link

Xiphin commented May 5, 2025

@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

@Xiphin
Copy link

Xiphin commented May 5, 2025

echo $GOCTL_EXPERIMENTAL

off

@kesonan
Copy link
Collaborator

kesonan commented May 5, 2025

@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

@Xiphin
Copy link

Xiphin commented May 5, 2025

@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

可行,可以用了

@Xiphin
Copy link

Xiphin commented May 5, 2025

没设置时, 提示 no such file or directory 功能是不是还需要优化一下,没有目录自动创建对应目录

@kesonan
Copy link
Collaborator

kesonan commented May 5, 2025

@Xiphin pls Add my wechat iikeson, let me reproduce this bug

方便加一下我的微信吗,微信号 iikeson, 我看一下你的 api 怎么定义的,我复现一下。

@Xiphin
Copy link

Xiphin commented May 5, 2025

@Xiphin pls Add my wechat iikeson, let me reproduce this bug

方便加一下我的微信吗,微信号 iikeson, 我看一下你的 api 怎么定义的,我复现一下。

加你了 通过一下

kesonan added a commit to kesonan/go-zero that referenced this issue May 5, 2025
@kesonan
Copy link
Collaborator

kesonan commented May 11, 2025

@kevwan 最新版生成 types.go 文件存在问题,使用 v1.8.2 时是正常的 使用 v1.8.3 时报错

it fixed on pr #4849

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/goctl Categorizes issue or PR as related to goctl.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants