a41f938cec
As we have seen, dependencies version can prevent the build. We should user lock versions on dependencies that we know work: * Packages are vendored * Add Godep support * Added addtional install step in readme * Fix travis build error
25 lignes
371 o
Go
25 lignes
371 o
Go
package humanize
|
|
|
|
import "strconv"
|
|
|
|
// Ordinal gives you the input number in a rank/ordinal format.
|
|
//
|
|
// Ordinal(3) -> 3rd
|
|
func Ordinal(x int) string {
|
|
suffix := "th"
|
|
switch x % 10 {
|
|
case 1:
|
|
if x%100 != 11 {
|
|
suffix = "st"
|
|
}
|
|
case 2:
|
|
if x%100 != 12 {
|
|
suffix = "nd"
|
|
}
|
|
case 3:
|
|
if x%100 != 13 {
|
|
suffix = "rd"
|
|
}
|
|
}
|
|
return strconv.Itoa(x) + suffix
|
|
}
|