Documentation
¶
Overview ¶
http://blog.csdn.net/siddontang/article/details/23541587 reflect.StringHeader和reflect.SliceHeader的结构体只相差末尾一个字段(cap) vitess代码,一种很hack的做法,string和slice的转换只需要拷贝底层的指针,而不是内存拷贝。
2016/09/28 Package gxstrings implements string related utilities.
2016/09/23 Package gxstrings implements string related utilities.
Index ¶
- func ArrayRemoveAt(a interface{}, i int)
- func BytePointer(b []byte) unsafe.Pointer
- func Contains(s []string, e string) bool
- func IsNil(i interface{}) bool
- func Merge(s1 []string, s2 []string) []string
- func RandStringBytesMaskImprSrc(n int) string
- func Slice(s string) (b []byte)
- func String(b []byte) (s string)
- func StringLength(s string) int
- func StringPointer(s string) unsafe.Pointer
- type Builder
- func (b *Builder) Buffer() []byte
- func (b *Builder) Grow(n int)
- func (b *Builder) Len() int
- func (b *Builder) Reset()
- func (b *Builder) String() string
- func (b *Builder) Write(p []byte) (int, error)
- func (b *Builder) WriteByte(c byte) error
- func (b *Builder) WriteRune(r rune) (int, error)
- func (b *Builder) WriteString(s string) (int, error)
- type UUID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayRemoveAt ¶
func ArrayRemoveAt(a interface{}, i int)
code example: output: // data len: 2 , cap: 3 , data: [one two] // data2 len: 2 , cap: 3 , data: [1 3]
data := []string{"one", "two", "three"} ArrayRemoveAt(&data, 2) fmt.Println("data len:", len(data), ", cap:", cap(data), ", data:", data)
data2 := []int{1, 2, 3} ArrayRemoveAt(&data2, 1) fmt.Println("data2 len:", len(data2), ", cap:", cap(data2), ", data:", data2)
func BytePointer ¶
returns &b[0], which is not allowed in go
func StringPointer ¶
returns &s[0], which is not allowed in go
Types ¶
type Builder ¶ added in v0.3.0
type Builder struct {
// contains filtered or unexported fields
}
A Builder is used to efficiently build a string using Write methods. It minimizes memory copying. The zero value is ready to use. Do not copy a non-zero Builder.
func (*Builder) Grow ¶ added in v0.3.0
Grow grows b's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to b without another allocation. If n is negative, Grow panics.
func (*Builder) Len ¶ added in v0.3.0
Len returns the number of accumulated bytes; b.Len() == len(b.String()).
func (*Builder) Reset ¶ added in v0.3.0
func (b *Builder) Reset()
Reset resets the Builder to be empty.
func (*Builder) Write ¶ added in v0.3.0
Write appends the contents of p to b's buffer. Write always returns len(p), nil.
func (*Builder) WriteByte ¶ added in v0.3.0
WriteByte appends the byte c to b's buffer. The returned error is always nil.