Created
July 28, 2020 10:35
-
-
Save tomill/63d9987cb02702404cbd7a1da045e27c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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