goctl api dart generates http api error
Author: ijkbytesCreated Apr 12, 2025Updated Aug 29, 2026
Labelskind/bugstalearea/goctl
Describe the bug When running the goctl api dart command with a specified API file which has embed struct, it fails with an error indicating a template execution failure. The error occurs when trying to call the getPropertyFromMember function on an empty string.
To Reproduce Steps to reproduce the behavior, if applicable:
- The API is
syntax = "v1"
type (
Common {
ID int `json:"id"`
}
HealthReq {}
HealthRsp {
Common
}
)
@server (
prefix: /test
group: test
)
service main {
@handler GetSomeTestHandler
get /some-test (HealthReq) returns (HealthRsp)
}
Run
goctl api dart --hostname "xxx.com" --scheme "https" --api ./test.api --dir ./darkThe error is
2025/04/12 11:53:22 template: dataTemplate:23:35: executing "dataTemplate" at <getPropertyFromMember .>: error calling getPropertyFromMember: cannot get property name of ""Expected behavior No error
Source: zeromicro/go-zero