Commit d38547d0 authored by AlexStocks's avatar AlexStocks

Mod: add bytes introduction

parent 44a37e92
......@@ -2,6 +2,14 @@
A go sdk for [Apache Dubbo-go](github.com/apache/dubbo-go).
## bytes
* BytesBufferPool
> bytes.Buffer pool
* SlicePool
> slice pool
## sync
> deadlock
......@@ -10,9 +18,8 @@ Copy from [go-deadlock](https://github.com/sasha-s/go-deadlock) and add EnableDe
## strings
> string <--> slice
Convert from string to slice or from slice to string asap.
* IsNil
> check a var is nil or not.
## time
......
// Copyright 2016 ~ 2018 AlexStocks(https://github.com/AlexStocks).
// All rights reserved. Use of this source code is
// governed by Apache License 2.0.
package gxstrings
import (
"reflect"
"unsafe"
)
// returns &s[0], which is not allowed in go
func StringPointer(s string) unsafe.Pointer {
p := (*reflect.StringHeader)(unsafe.Pointer(&s))
return unsafe.Pointer(p.Data)
}
// returns &b[0], which is not allowed in go
func BytePointer(b []byte) unsafe.Pointer {
p := (*reflect.SliceHeader)(unsafe.Pointer(&b))
return unsafe.Pointer(p.Data)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment