iso4217

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2023 License: MIT Imports: 0 Imported by: 3

README

iso4217

Go Reference

Golang convenience library containing ISO 4217 currency codes

Documentation

Overview

Package iso4217 is a convenience library containing ISO 4217 currency codes

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByCode

func ByCode(n int) (string, int)

ByCode resolves the given code to the 3 character string and the number of minor unit digits to display for the given currency.

Example
package main

import (
	"fmt"

	"github.com/rmg/iso4217"
)

func main() {
	name, minor := iso4217.ByCode(0)
	fmt.Printf("name: '%s', minor: %d\n", name, minor)
}
Output:

name: '', minor: 0
Example (Cad)
package main

import (
	"fmt"

	"github.com/rmg/iso4217"
)

func main() {
	name, minor := iso4217.ByCode(124)
	fmt.Printf("name: '%s', minor: %d\n", name, minor)
}
Output:

name: 'CAD', minor: 2
Example (Unknown)
package main

import (
	"fmt"

	"github.com/rmg/iso4217"
)

func main() {
	name, minor := iso4217.ByCode(1234591)
	fmt.Printf("name: '%s', minor: %d\n", name, minor)
}
Output:

name: '', minor: 0
Example (Xxx)
package main

import (
	"fmt"

	"github.com/rmg/iso4217"
)

func main() {
	name, minor := iso4217.ByCode(999)
	fmt.Printf("name: '%s', minor: %d\n", name, minor)
}
Output:

name: 'XXX', minor: 0

func ByName

func ByName(s string) (int, int)

ByName resolves the given name to the numeric code and the number of minor unit digits to display for the given currency.

Example
package main

import (
	"fmt"

	"github.com/rmg/iso4217"
)

func main() {
	code, minor := iso4217.ByName("")
	fmt.Printf("code: %d, minor: %d\n", code, minor)
}
Output:

code: 0, minor: 0
Example (Cad)
package main

import (
	"fmt"

	"github.com/rmg/iso4217"
)

func main() {
	code, minor := iso4217.ByName("CAD")
	fmt.Printf("code: %d, minor: %d\n", code, minor)
}
Output:

code: 124, minor: 2
Example (Unknown)
package main

import (
	"fmt"

	"github.com/rmg/iso4217"
)

func main() {
	code, minor := iso4217.ByName("NOT_REAL")
	fmt.Printf("code: %d, minor: %d\n", code, minor)
}
Output:

code: 0, minor: 0
Example (Xxx)
package main

import (
	"fmt"

	"github.com/rmg/iso4217"
)

func main() {
	code, minor := iso4217.ByName("XXX")
	fmt.Printf("code: %d, minor: %d\n", code, minor)
}
Output:

code: 999, minor: 0

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL