Skip to content

Instantly share code, notes, and snippets.

@sklinkert
Last active January 29, 2021 20:08
Show Gist options
  • Save sklinkert/ccf14477af04ff3f360afe25456dd37d to your computer and use it in GitHub Desktop.
Save sklinkert/ccf14477af04ff3f360afe25456dd37d to your computer and use it in GitHub Desktop.
German numbers (format numbers properly)
package main
import (
"fmt"
"golang.org/x/text/language"
"golang.org/x/text/message"
)
func germanNumber(n float64) string {
p := message.NewPrinter(language.German)
return p.Sprintf("%.2f", n)
}
func main() {
fmt.Println(germanNumber(1000.05))
// 1.000,05
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment