How do their APIs compare?
How do their APIs compare?
About shopspring/decimal · 2 messages · last activity 9/9/2026
I can only meaningfully answer this for shopspring/decimal, since unknwon/the-way-to-go_zh_cn is not a software library with an API — it's a Chinese-language translation/learning resource for "The Way to Go," a book about Go programming. It doesn't expose functions, types, or a public interface in the way shopspring/decimal does; it's a documentation/tutorial repo (chapters, exercises, code samples used for teaching), not a package consumers import.
So there isn't really an "API" to compare between the two — one is a library, the other is educational content. Let me give you a bit more grounding on the decimal side so this is concrete, since that's the repo with an actual API surface.
From the README excerpt:
decimal.NewFromString(s string) (Decimal, error)— parse a decimal from a stringdecimal.NewFromInt(i int64) Decimal— construct from an intdecimal.NewFromFloat(f float64) Decimal— construct from a float- Arithmetic methods on
Decimalvalues:Add,Sub,Mul,Div(with specified precision), as shown in the usage example in the README. - The zero-value
Decimal{}is usable as 0 without explicit initialization (a deliberate API design choice noted in the README). - It also supports
database/sqlserialization and JSON/XML marshaling, meaningDecimalimplements interfaces likesql.Scanner/driver.Valuerand JSON/XML marshal/unmarshal methods, though I don't have the exact method signatures loaded from source in this context — I'd need to search the code if you want the precise line numbers for those implementations.
If you'd like, I can search the decimal source for the exact signatures of Div, MarshalJSON, Scan, etc., to give you precise citations. And if by "their APIs" you actually meant something else (e.g., comparing decimal's API to another Go decimal library mentioned in its README, like cockroachdb/apd), let me know and I can dig into that comparison using the README's "Alternative libraries" section as a starting point — though I'd be limited to what's said there since apd itself isn't part of this repository data.
Do you want me to pull more detail from the decimal source (e.g., Div, Round, JSON/XML methods) with exact line citations?
FOLLOW_UPS:
- Show exact signatures for Decimal's Div and Round methods?
- What does the-way-to-go_zh_cn repo actually contain?
- Explain decimal's JSON/XML marshaling implementation details?
Want to ask your own question?
Open chat for shopspring/decimalPublic Q&A. Generated by RepoPilot from the actual source of shopspring/decimal. AI answers can be incomplete or stale — verify before relying on them.