go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

add support for time.Time type

Open Extraordinary01 opened this issue 1 month ago • 3 comments

When we are writing .api contract for gateway service, probably the common data type, that we are getting from request is time.Time type. Go handles parsing of time.Time if it's format is RFC3379. I suggest you to add time.Time supporting for .api files. Otherwise, we must use string for time and then parsing it by ourselves in the logic, which is not comfortable. I can do it by myself and be a contributor, if there is any rules in your project. Thanks

Extraordinary01 avatar Nov 10 '25 12:11 Extraordinary01

I think we need to check which programming languages can parse time.Time. For example TypeScript, JavaScript, Dart, Java, etc. Lots of users use .api files to generate code in different languages.

kevwan avatar Nov 16 '25 11:11 kevwan

I totally agree the need for time.Time type in .api files. However, given the different kinds of formatting of time strings could be, I could feel the large obstacle in implementing it. Also kevwan mentioned the difficulties about different languanges.

ez4bk avatar Dec 08 '25 06:12 ez4bk

I think we need to check which programming languages can parse time.Time. For example TypeScript, JavaScript, Dart, Java, etc. Lots of users use .api files to generate code in different languages.

Can't we just use select, case like statement for these languages or at least, add support for time.Time only for Golang? Or it's not possible?

Extraordinary01 avatar Dec 08 '25 06:12 Extraordinary01