num2words

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: MIT Imports: 2 Imported by: 0

README

Number to Words

CircleCI Coverage Status Go Reference

Golang package to convert number into words. For example : 148 become one hundred forty-eight. Inspired by this python library num2words.

Install

Run go get -u github.com/vinbyte/num2words

Usage

package main

import (
	"fmt"
	"github.com/vinbyte/num2words"
)

func main() {
	n2w := num2words.New("en")
	res := n2w.NumberToWord(349)
	fmt.Println(res)
}
//output : three hundred forty-nine

Test

Run go test -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type N2w

type N2w struct {
	NumberToWord       func(int64) string
	NumberToOrdinal    func(int64) string
	NumberToOrdinalNum func(int64) string
}

N2w hold some function represent its feature

func New

func New(lang string, options ...N2wOption) *N2w

New initiate new converter

type N2wOption

type N2wOption func()

N2wOption is optional option to setting some data, like customNegativeWord, etc.

func CustomNegativeWord

func CustomNegativeWord(value string) N2wOption

CustomNegativeWord is function to set the custom word of negative sign

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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