2948 explained code solutions for 75 technologies


golangHow to add thousands comma separator to a number


package main

import "golang.org/x/text/language"
import "golang.org/x/text/message"
import "fmt"

func main() {
  p := message.NewPrinter(language.English)
  s := p.Sprintf("%d", 12398712983)
  fmt.Println(s)
}ctrl + c
package main

default package declaration

import "fmt"

loads fmt package to operate on strings (and print them)

golang.org/x/text

enables localization capabilities

message.NewPrinter(language.English)

create localized English printer

12398712983

sample number to add thousands separator to

fmt.Println

prints specified string