Skip to content

A library providing ISO4217 currency codes and minor units

License

Notifications You must be signed in to change notification settings

ladydascalie/currency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

currency

This package generates structs containing all the up-to-date ISO4217 currency codes and minor units, along with a very simple validator.

Data is graciously provided by:

Usage:

package main

import (
	"fmt"
	"github.com/ladydascalie/currency"
)

func main() {
	// Validate currency code.
	if !currency.Valid("ABC") {
		// Handle invalid currency code.
		fmt.Println("Invalid currency code")
	}

	// Retrieve and print currency values.
	fmt.Println(currency.USD.Code())      // Output: USD
	fmt.Println(currency.USD.MinorUnit()) // Output: 2
}