template: constants should be generated with type?
Closed this issue · 3 comments
Describe the bug
const
definition is generated without specified type.
eg.
xxx.thrift
typedef string MyString
const MyString OK = "ok"
const MyString Err = "err"
const i32 StatusOK = 200
const i32 StatusErr = 500
got:
const (
OK = "ok"
Err = "err"
StatusOK = 200
StatusErr = 500
)
type MyString = string
To Reproduce
Steps to reproduce the behavior:
thriftgo --gen go --out xxx xxx.thrift
Expected behavior
constants should be generated with type like
const (
OK MyString = "ok"
Err MyString = "err"
StatusOK int32 = 200
StatusErr int32 = 500
)
type MyString = string
Screenshots
If applicable, add screenshots to help explain your problem.
**Kitex version: v1.15.3
Please provide the version of Kitex you are using.
Environment:
The output of go env
.
Additional context
https://github.com/cloudwego/thriftgo/blob/main/generator/golang/templates/constant.go#L26
May I ask what is the necessity of doing this? It seems that the current way is also okay.
It's confusing for client users to find optional values of that type. In my opinion, when typedef types and corresponding values are defined, it is to inform users of the available values of that type.
Currently we don't have plan to support this. If you're interested in it, you can create a pr to implement it and add some tests.