aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8.1/libgo/go/bytes/example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.8.1/libgo/go/bytes/example_test.go')
-rw-r--r--gcc-4.8.1/libgo/go/bytes/example_test.go68
1 files changed, 0 insertions, 68 deletions
diff --git a/gcc-4.8.1/libgo/go/bytes/example_test.go b/gcc-4.8.1/libgo/go/bytes/example_test.go
deleted file mode 100644
index dc66b6a40..000000000
--- a/gcc-4.8.1/libgo/go/bytes/example_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2011 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 bytes_test
-
-import (
- "bytes"
- "encoding/base64"
- "fmt"
- "io"
- "os"
- "sort"
-)
-
-func ExampleBuffer() {
- var b bytes.Buffer // A Buffer needs no initialization.
- b.Write([]byte("Hello "))
- fmt.Fprintf(&b, "world!")
- b.WriteTo(os.Stdout)
- // Output: Hello world!
-}
-
-func ExampleBuffer_reader() {
- // A Buffer can turn a string or a []byte into an io.Reader.
- buf := bytes.NewBufferString("R29waGVycyBydWxlIQ==")
- dec := base64.NewDecoder(base64.StdEncoding, buf)
- io.Copy(os.Stdout, dec)
- // Output: Gophers rule!
-}
-
-func ExampleCompare() {
- // Interpret Compare's result by comparing it to zero.
- var a, b []byte
- if bytes.Compare(a, b) < 0 {
- // a less b
- }
- if bytes.Compare(a, b) <= 0 {
- // a less or equal b
- }
- if bytes.Compare(a, b) > 0 {
- // a greater b
- }
- if bytes.Compare(a, b) >= 0 {
- // a greater or equal b
- }
-
- // Prefer Equal to Compare for equality comparisons.
- if bytes.Equal(a, b) {
- // a equal b
- }
- if !bytes.Equal(a, b) {
- // a not equal b
- }
-}
-
-func ExampleCompare_search() {
- // Binary search to find a matching byte slice.
- var needle []byte
- var haystack [][]byte // Assume sorted
- i := sort.Search(len(haystack), func(i int) bool {
- // Return haystack[i] >= needle.
- return bytes.Compare(haystack[i], needle) >= 0
- })
- if i < len(haystack) && bytes.Equal(haystack[i], needle) {
- // Found it!
- }
-}