github.com/zhongdalu/gf@v1.0.0/g/encoding/gbinary/gbinary.go (about) 1 // Copyright 2017 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/zhongdalu/gf. 6 7 // Package gbinary provides useful API for handling binary/bytes data. 8 // 9 // 注意gbinary模块默认使用LittleEndian进行编码。 10 package gbinary 11 12 func Encode(values ...interface{}) []byte { 13 return LeEncode(values...) 14 } 15 16 func EncodeByLength(length int, values ...interface{}) []byte { 17 return LeEncodeByLength(length, values...) 18 } 19 20 func Decode(b []byte, values ...interface{}) error { 21 return LeDecode(b, values...) 22 } 23 24 func EncodeString(s string) []byte { 25 return LeEncodeString(s) 26 } 27 28 func DecodeToString(b []byte) string { 29 return LeDecodeToString(b) 30 } 31 32 func EncodeBool(b bool) []byte { 33 return LeEncodeBool(b) 34 } 35 36 func EncodeInt(i int) []byte { 37 return LeEncodeInt(i) 38 } 39 40 func EncodeUint(i uint) []byte { 41 return LeEncodeUint(i) 42 } 43 44 func EncodeInt8(i int8) []byte { 45 return LeEncodeInt8(i) 46 } 47 48 func EncodeUint8(i uint8) []byte { 49 return LeEncodeUint8(i) 50 } 51 52 func EncodeInt16(i int16) []byte { 53 return LeEncodeInt16(i) 54 } 55 56 func EncodeUint16(i uint16) []byte { 57 return LeEncodeUint16(i) 58 } 59 60 func EncodeInt32(i int32) []byte { 61 return LeEncodeInt32(i) 62 } 63 64 func EncodeUint32(i uint32) []byte { 65 return LeEncodeUint32(i) 66 } 67 68 func EncodeInt64(i int64) []byte { 69 return LeEncodeInt64(i) 70 } 71 72 func EncodeUint64(i uint64) []byte { 73 return LeEncodeUint64(i) 74 } 75 76 func EncodeFloat32(f float32) []byte { 77 return LeEncodeFloat32(f) 78 } 79 80 func EncodeFloat64(f float64) []byte { 81 return LeEncodeFloat64(f) 82 } 83 84 func DecodeToInt(b []byte) int { 85 return LeDecodeToInt(b) 86 } 87 88 func DecodeToUint(b []byte) uint { 89 return LeDecodeToUint(b) 90 } 91 92 func DecodeToBool(b []byte) bool { 93 return LeDecodeToBool(b) 94 } 95 96 func DecodeToInt8(b []byte) int8 { 97 return LeDecodeToInt8(b) 98 } 99 100 func DecodeToUint8(b []byte) uint8 { 101 return LeDecodeToUint8(b) 102 } 103 104 func DecodeToInt16(b []byte) int16 { 105 return LeDecodeToInt16(b) 106 } 107 108 func DecodeToUint16(b []byte) uint16 { 109 return LeDecodeToUint16(b) 110 } 111 112 func DecodeToInt32(b []byte) int32 { 113 return LeDecodeToInt32(b) 114 } 115 116 func DecodeToUint32(b []byte) uint32 { 117 return LeDecodeToUint32(b) 118 } 119 120 func DecodeToInt64(b []byte) int64 { 121 return LeDecodeToInt64(b) 122 } 123 124 func DecodeToUint64(b []byte) uint64 { 125 return LeDecodeToUint64(b) 126 } 127 128 func DecodeToFloat32(b []byte) float32 { 129 return LeDecodeToFloat32(b) 130 } 131 132 func DecodeToFloat64(b []byte) float64 { 133 return LeDecodeToFloat64(b) 134 }