Documentation
¶
Index ¶
- Variables
- func BinaryToStruct(p interface{}, bPtr *[]byte)
- func ByteToString(b byte) string
- func BytesToString(p interface{}) string
- func ErrorCatch(err error)
- func Expect(p1, p2 interface{})
- func FreeAllocator(a *Allocator)
- func GetAddr(p interface{}) uintptr
- func GetMD5(b []byte) []byte
- func GetMD5String(b []byte) string
- func GetSize(p interface{}) int
- func IPV4AddrToByte(addr string, bPtr *[]byte)
- func LogTrace(b []byte)
- func SetBytes(p interface{}, offset int, new []byte)
- func SizeOf(p interface{}) int
- func SprintfAddress(addr string, port int) string
- func StringToByte(s string, b *byte)
- func StructToBinary(p interface{}) *[]byte
- func ToBinary(p interface{}, size int) *[]byte
- func ToStruct(p interface{}, bPtr *[]byte, size int)
- type Allocator
Constants ¶
This section is empty.
Variables ¶
var Console console
var ErrNeedPointer = errors.New("p must be a pointer")
var PtrSize uintptr
Functions ¶
func BinaryToStruct ¶
func BinaryToStruct(p interface{}, bPtr *[]byte)
p must be a pointer to a struct. set p to whatever bPtr holds. it's a little bit slower than ToStruct.
func ByteToString ¶
func BytesToString ¶
func BytesToString(p interface{}) string
p is a pointer to a byte array,not a slice.
func ErrorCatch ¶
func ErrorCatch(err error)
func FreeAllocator ¶
func FreeAllocator(a *Allocator)
func GetMD5String ¶
func GetSize ¶
func GetSize(p interface{}) int
GetSize uses reflect,will be a little slow,but it is safe. panic when arg p is not a pointer to a struct.
func IPV4AddrToByte ¶
func SizeOf ¶
func SizeOf(p interface{}) int
SizeOf is much faster,get underlying size. p shoule be a value of a struct to get the size of a struct instance.
func SprintfAddress ¶
func StringToByte ¶
convert only byte. 5 = 5 * 10 ^ 0 61 = 6 * 10 ^ 1 + 1 * 10 ^ 0 121 = 1 * 10 ^ 2 + 2 * 10 ^ 1 + 1 * 10 ^ 0
func StructToBinary ¶
func StructToBinary(p interface{}) *[]byte
p must be a pointer to a struct StructToBinary() will return a pointer to byte slice p covers in the memory. return a pointer to a byte slice whose undelying pointer to point to p and size is real size of p. so it is safe. The underlying byte slice is a struct,so the data of slice field in a struct is not correct.
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}