diff options
Diffstat (limited to 'content/strings/basic.go')
-rw-r--r-- | content/strings/basic.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/content/strings/basic.go b/content/strings/basic.go new file mode 100644 index 0000000..7397067 --- /dev/null +++ b/content/strings/basic.go @@ -0,0 +1,46 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "fmt" + +func main() { + // const string OMIT + const sample = "\xbd\xb2\x3d\xbc\x20\xe2\x8c\x98" + // const string OMIT + + fmt.Println("Println:") + // println OMIT + fmt.Println(sample) + // println OMIT + + fmt.Println("Byte loop:") + // byte loop OMIT + for i := 0; i < len(sample); i++ { + fmt.Printf("%x ", sample[i]) + } + // byte loop OMIT + fmt.Printf("\n") + + fmt.Println("Printf with %x:") + // percent x OMIT + fmt.Printf("%x\n", sample) + // percent x OMIT + + fmt.Println("Printf with % x:") + // percent space x OMIT + fmt.Printf("% x\n", sample) + // percent space x OMIT + + fmt.Println("Printf with %q:") + // percent q OMIT + fmt.Printf("%q\n", sample) + // percent q OMIT + + fmt.Println("Printf with %+q:") + // percent plus q OMIT + fmt.Printf("%+q\n", sample) + // percent plus q OMIT +} |