jaswdr / faker

:rocket: Ultimate fake data generator for Go with zero dependencies

Home Page:https://pkg.go.dev/github.com/jaswdr/faker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE] Add a currency generator

d-krasichkov opened this issue · comments

Is your feature request related to a problem? Please describe.
To test applications, that are somehow connected with the financial field, would be helpful to have a currency generator.

Describe the solution you'd like
I’d like to implement a currency generator, that could return a random currency name and code.

Describe alternatives you've considered
Also, I’m thinking about adding currency symbols, but I’m not sure whatever it is really so useful in server-side development. What do you think?

Hello @d-krasichkov, thank you for opening the issue, I've collected the list of Currencies from the ISO 4217 updated to Jan/2022. It is available starting from release v1.9.0, se bellow some examples:

package main

import (
        "fmt"

        "github.com/jaswdr/faker"
)

func main() {
        f := faker.New()
        c := f.Currency()
        fmt.Println(c.Currency())
        fmt.Println(c.Code())
        fmt.Println(c.Country())
        fmt.Println(c.Number())

    currency, code := c.CurrencyAndCode()
        fmt.Println(currency, code)
}
// US Dollar
// EUR
// MACAO
// 654
// CFA Franc BCEAO XOF