package byt
import "fmt"
import "bytes"
func Start() {
b1 :=[]byte("### ###")
fmt.Println(string(bytes.Trim(b1,"#")))
fmt.Println("=====================")
b2 := []byte("Google")
b3 := []byte("google")
fmt.Println(bytes.Compare(b2,b3))
fmt.Println(bytes.Contains(b2,[]byte("goo")))
fmt.Println(bytes.Contains(b2,[]byte("Goo")))
var bb = &bytes.Buffer{}
bb.Len()
bb.WriteByte(byte('x'))
fmt.Println(bb.Len())
fmt.Println("=======byte read =========")
//var b4 byte;
b5,_:= bb.ReadByte();
fmt.Println(string(b5))
fmt.Println("============== bytes.Fields=====================")
for _,v := range bytes.Fields([]byte(" ")){
fmt.Println(string(v))
}
fmt.Println("============== bytes.FieldsFunc=====================")
f1 :=func(r rune) bool{
if r == ',' {
return true
} else {
return false
}
}
for _,v := range bytes.FieldsFunc([]byte(" , , , "),f1){
fmt.Println(string(v))
}
fmt.Println("====================IndexRune================================")
fmt.Println(bytes.IndexRune([]byte(" , "),rune(' ')))
fmt.Println("====================HasPrefix================================")
fmt.Println(bytes.HasPrefix([]byte(" , "),[]byte(" ")))
fmt.Println("==============================================")
fmt.Println(bytes.HasSuffix([]byte(" , "),[]byte(" ")))
fmt.Println("=====================NewBuffer=========================")
var bbs *bytes.Buffer = bytes.NewBuffer([]byte(" "))
fmt.Println(string(bbs.Bytes()),bbs.Len(),bbs.Cap())
var bs = []byte("xxxxxxxxxxxx")
var reader *bytes.Reader = bytes.NewReader(bs)
fmt.Println(reader.Len(),reader.Size())
}
D:/work/software/go1.5.windows-386/go/bin/go.exe build -i [D:/go/stu/src/app]
: 0.
D:/go/stu/src/app/app.exe [D:/go/stu/src/app]
==============
strings eq : true
strings Repeat : dongtiangdongtiangdongtiangdongtiangdongtiangdongtiangdongtiangdongtiangdongtiangdongtiang
22825
=====
' ' Unicode 。
========bytes =======
=====================
-1
false
true
1
=======byte read =========
x
============== bytes.Fields=====================
============== bytes.FieldsFunc=====================
====================IndexRune================================
4
====================HasPrefix================================
true
==============================================
true
=====================NewBuffer=========================
6 32
12 12
: 0.