Skip to content

Instantly share code, notes, and snippets.

@tomill
Created July 28, 2020 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomill/63d9987cb02702404cbd7a1da045e27c to your computer and use it in GitHub Desktop.
Save tomill/63d9987cb02702404cbd7a1da045e27c to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/nkall/compactnumber"
"golang.org/x/text/language"
)
type compact int
func (v compact) String() string {
formatter := compactnumber.NewFormatter(language.Japanese.String(), compactnumber.Short)
out, _ := formatter.Format(int(v))
return out
}
func ExampleF() {
fmt.Printf("私の戦闘力は%sです", compact(530000))
// Output: 私の戦闘力は53万です
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment