-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:Goctl can't generate the type of decimal. #3441
Comments
The issue can be fixed if you add decimal type to variable type map 1. The decimal type is added to goctl1.1 You can add decimal type as below,
1.2 And build goctl with below command,
2. How to use decimal typeI use decimal library (https://github.com/shopspring/decimal) to support decimal type 3. Example3.1 Create greet.api as below
3.2 Generate code
the generated files look like: ├── greet 3.3 decimal change for the file type.gowe need import decimal library and change decimal type to decimal.Decimal in file internal/types/types.go
3.4 Update result(not neccessary) in the file internal/logic/greetlogic.go
3.5 Run and checkrun the server you can check result by curl
Thanks, |
You're welcome, this is much better than saving money with the int64 type. Thank you for taking my advice! |
see features #4062 |
see features #4062 |
As we all know, if using int or float instead of decimal, there may be precision loss, which is fatal for finance. We hope thatdevelopers can enable goct to generate the type of decimal.Decimal to resolve this question.
The text was updated successfully, but these errors were encountered: