ISO 4217 - Currency Codes
The iso4217 package provides typed constants for ISO 4217 currency codes.
Type
Code
Three-letter currency code (e.g., USD, EUR, GBP).
go
type Code stringMethods:
| Method | Description |
|---|---|
String() string | Returns the string representation |
Valid() bool | Returns true if the code is a valid ISO 4217 currency code |
Usage
go
package main
import (
"fmt"
"github.com/foomo/gostandards/iso4217"
)
func main() {
currency := iso4217.CodeUSD
fmt.Println(currency) // "USD"
fmt.Println(currency.Valid()) // true
// Validation
invalid := iso4217.Code("XXX")
fmt.Println(invalid.Valid()) // false
}Constants
Constants follow the naming convention CodeXXX, where the suffix is the currency code:
go
iso4217.CodeUSD // "USD" - US Dollar
iso4217.CodeEUR // "EUR" - Euro
iso4217.CodeGBP // "GBP" - Pound Sterling
iso4217.CodeJPY // "JPY" - Yen
iso4217.CodeCHF // "CHF" - Swiss Franc
iso4217.CodeAUD // "AUD" - Australian DollarThe full list contains 180+ currency codes. See the source code for all constants.
Code Generation
The constants are generated from official ISO data sources. Do not edit the generated files directly — run make generate to regenerate them.
