A numeral utility package for Go
To install the numeral library run:
go get github.com/suft/numeral
numeral.Ordinal
is a function that returns the English ordinal letters following a numeral.
package main
import (
"fmt"
"os"
"github.com/suft/numeral"
)
func main() {
visitor, err := numeral.Ordinal(2)
if err != nil {
return fmt.Fprintf(os.Stderr, "invalid value")
os.Exit(1)
}
fmt.Printf("You are the %s visitor", visitor)
}
You are the 2nd visitor
package main
import (
"fmt"
"github.com/suft/numeral"
)
func main() {
visitor, _ := numeral.Ordinal(3)
fmt.Printf("You are the %s visitor", visitor)
}
You are the 3rd visitor
If you encounter any problems, please file an issue along with a detailed description.
Contributions are welcome, and they are greatly appreciated! Every little bit helps.
Distributed under the terms of the MIT license, numeral is free and open source software.