github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/blog/content/strings/basic.go (about) 1 // +build OMIT 2 3 // Copyright 2013 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 package main 8 9 import "fmt" 10 11 func main() { 12 // const string OMIT 13 const sample = "\xbd\xb2\x3d\xbc\x20\xe2\x8c\x98" 14 // const string OMIT 15 16 fmt.Println("Println:") 17 // println OMIT 18 fmt.Println(sample) 19 // println OMIT 20 21 fmt.Println("Byte loop:") 22 // byte loop OMIT 23 for i := 0; i < len(sample); i++ { 24 fmt.Printf("%x ", sample[i]) 25 } 26 // byte loop OMIT 27 fmt.Printf("\n") 28 29 fmt.Println("Printf with %x:") 30 // percent x OMIT 31 fmt.Printf("%x\n", sample) 32 // percent x OMIT 33 34 fmt.Println("Printf with % x:") 35 // percent space x OMIT 36 fmt.Printf("% x\n", sample) 37 // percent space x OMIT 38 39 fmt.Println("Printf with %q:") 40 // percent q OMIT 41 fmt.Printf("%q\n", sample) 42 // percent q OMIT 43 44 fmt.Println("Printf with %+q:") 45 // percent plus q OMIT 46 fmt.Printf("%+q\n", sample) 47 // percent plus q OMIT 48 }