golang.org/x/text@v0.14.0/cases/example_test.go (about) 1 // Copyright 2014 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 cases_test 6 7 import ( 8 "fmt" 9 10 "golang.org/x/text/cases" 11 "golang.org/x/text/language" 12 ) 13 14 func Example() { 15 src := []string{ 16 "hello world!", 17 "i with dot", 18 "'n ijsberg", 19 "here comes O'Brian", 20 } 21 for _, c := range []cases.Caser{ 22 cases.Lower(language.Und), 23 cases.Upper(language.Turkish), 24 cases.Title(language.Dutch), 25 cases.Title(language.Und, cases.NoLower), 26 } { 27 fmt.Println() 28 for _, s := range src { 29 fmt.Println(c.String(s)) 30 } 31 } 32 33 // Output: 34 // hello world! 35 // i with dot 36 // 'n ijsberg 37 // here comes o'brian 38 // 39 // HELLO WORLD! 40 // İ WİTH DOT 41 // 'N İJSBERG 42 // HERE COMES O'BRİAN 43 // 44 // Hello World! 45 // I With Dot 46 // 'n IJsberg 47 // Here Comes O'brian 48 // 49 // Hello World! 50 // I With Dot 51 // 'N Ijsberg 52 // Here Comes O'Brian 53 }