golang.org/x/text@v0.14.0/number/examples_test.go (about) 1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package number_test 6 7 import ( 8 "golang.org/x/text/language" 9 "golang.org/x/text/message" 10 "golang.org/x/text/number" 11 ) 12 13 func ExampleMaxIntegerDigits() { 14 const year = 1999 15 p := message.NewPrinter(language.English) 16 p.Println("Year:", number.Decimal(year, number.MaxIntegerDigits(2))) 17 18 // Output: 19 // Year: 99 20 } 21 22 func ExampleIncrementString() { 23 p := message.NewPrinter(language.English) 24 25 p.Println(number.Decimal(1.33, number.IncrementString("0.50"))) 26 27 // Output: 1.50 28 }