-
Notifications
You must be signed in to change notification settings - Fork 923
Type Alias in Code generation #3512
Unanswered
DawnKosmos
asked this question in
Feature Requests & Ideas
-
Hey, We would love to see following optional feature in Code Generation for Golang.
If a Struct that matches in FieldName, Type and Order should not generate a new Type but a Type alias
type InsertDailyParams struct {
TickerID int32 `json:"ticker_id"`
Open float64 `json:"open"`
High float64 `json:"high"`
Low float64 `json:"low"`
Close float64 `json:"close"`
Volume float64 `json:"volume"`
Time int64 `json:"time"`
}
type InsertHourlyParams = InsertDailyParams
Instead of this
/*
type InsertHourlyParams struct {
TickerID int32 `json:"ticker_id"`
Open float64 `json:"open"`
High float64 `json:"high"`
Low float64 `json:"low"`
Close float64 `json:"close"`
Volume float64 `json:"volume"`
Time int64 `json:"time"`
}
*/
I think it should be easy to implement
- Add an option to the yaml
- Add a map that hashes field.name + field.types of generated struct.
If someone wants to help me with this feature, I really appreciate it.
I wrote a tool that does this, after a sqlc generation, and it did not break our codebase.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
https://github.com/cubular-io/sqlcube If someone want to play with it.
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment