如何在 Go 中获取序号指示符(第 1、第 2、第 3 等)

How to get ordinal indicators (1st, 2nd, 3rd, etc) in Go

Go 的 time 包让我可以这样做:

time.Now().Format("2 January 2006")

其中 returns 类似于 10 November 2009

我可以使用 time 或任何标准 Go 包获得类似 10th November 2009 的东西吗?

可能的话time.Format documentation doesn't mention it, and I'd like to avoid doing it manually

内置 time 库不支持该功能。您需要自己实现功能,使用链接 Java 问题中描述的算法,或者使用可以为您完成的第三方库,例如 humanizehttps://godoc.org/github.com/dustin/go-humanize#Ordinal.