go-zero
go-zero copied to clipboard
Docs and comments are not retained when using goctl to generate code from api file
Describe the bug
The doc here says that it retain the original mark of //, /*, */. But when I generate code using go-ctl, docs and comments are removed (except inline comments)

To Reproduce Steps to reproduce the behavior, if applicable:
-
test.api file
syntax = "v1" info ( title: "test service" desc: "service to test bug" author: "" email: "" ) type PingReq { // State where ping request come from. From string `json:"from"` // eg: ip address, origin host } type PingResp { // Ack message. Message string `json:"message"` } service test-api { @handler HandlePing post /ping(PingReq) returns(PingResp) } -
Generate code using goctl
goctl api go -api test.api -
The generated
types.gofile, see that docs and comments are gone with the exception of inline comments// Code generated by goctl. DO NOT EDIT. package types type PingReq struct { From string `json:"from"` // eg: ip address, origin host } type PingResp struct { Message string `json:"message"` }
Expected behavior All docs and comments from api files were retained in produced types.go
Environments:
- OS: WSL Ubuntu
- go-zero version v1.4.0
- goctl version 1.4.0 linux/amd64
Comments and definitions can be brought into the generated code. example:
type PingResp {
Message string `json:"message"` // Ack message.
}
Yes I aware that inline comment is retained.
But what if I need to add multiline comments? I think it also need to be retained in the generated code because if I need to add complete documentation for a field, most likely it will be multiline comments
type PingResp {
// ACK message
// second line
Message string `json:"message"`
}
Not working?
It's not working. It will be removed on generated types.go file
@MarkJoyMa @anqiansong PTAL.
type PingResp { // ACK message // second line Message string `json:"message"` }Not working?
also not working for goctl-swagger. Only inline comments are maintained
hi team, any update on this?
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.