Documentation
¶
Index ¶
- Constants
- Variables
- func BigIntToIPv6(ipaddr big.Int) net.IP
- func CutIP(ip string) string
- func DecodeBool(buffer *bytes.Buffer) bool
- func DecodeBuffer(buffer *bytes.Buffer) *bytes.Buffer
- func DecodeBytes(buffer *bytes.Buffer) []byte
- func DecodeDecodable(decodable Decodable, buffer *bytes.Buffer) any
- func DecodeFloat32(buffer *bytes.Buffer) float32
- func DecodeFloat64(buffer *bytes.Buffer) float64
- func DecodeInt(buffer *bytes.Buffer) int
- func DecodeInt16(buffer *bytes.Buffer) int16
- func DecodeInt32(buffer *bytes.Buffer) int32
- func DecodeInt64(buffer *bytes.Buffer) int64
- func DecodeInt8(buffer *bytes.Buffer) int8
- func DecodeString(buffer *bytes.Buffer) string
- func DecodeUint16(buffer *bytes.Buffer) uint16
- func DecodeUint32(buffer *bytes.Buffer) uint32
- func DecodeUint64(buffer *bytes.Buffer) uint64
- func DecodeUint8(buffer *bytes.Buffer) uint8
- func EncodeBool(v bool, buffer *bytes.Buffer)
- func EncodeBuffer(v *bytes.Buffer, buffer *bytes.Buffer)
- func EncodeBytes(v []byte, buffer *bytes.Buffer)
- func EncodeEncodeable(v Encodeable, buffer *bytes.Buffer)
- func EncodeFloat32(v float32, buffer *bytes.Buffer)
- func EncodeFloat64(v float64, buffer *bytes.Buffer)
- func EncodeInt(v int, buffer *bytes.Buffer)
- func EncodeInt16(v int16, buffer *bytes.Buffer)
- func EncodeInt32(v int32, buffer *bytes.Buffer)
- func EncodeInt64(v int64, buffer *bytes.Buffer)
- func EncodeInt8(v int8, buffer *bytes.Buffer)
- func EncodeString(v string, buffer *bytes.Buffer)
- func EncodeUint16(v uint16, buffer *bytes.Buffer)
- func EncodeUint32(v uint32, buffer *bytes.Buffer)
- func EncodeUint64(v uint64, buffer *bytes.Buffer)
- func EncodeUint8(v uint8, buffer *bytes.Buffer)
- func IP2Int(ip net.IP) *big.Int
- func IPV4ToIPV6(ipv4 string) string
- func IPV6ToString(ipv6 *big.Int) string
- func IPv4ToInt(ipaddr net.IP) (uint32, error)
- func IPv6ToBigInt(ipaddr net.IP) *big.Int
- func IPv6ToInt(ipaddr net.IP) ([2]uint64, error)
- func IntToIPv4(ipaddr uint32) net.IP
- func IntToIPv6(high, low uint64) net.IP
- func MergeStruct(record1 interface{}, record2 interface{}) error
- func ParseIP(s string) (net.IP, int, error)
- type BinaryDecoder
- type BinaryEncoder
- type Decodable
- type Encodeable
Constants ¶
const ( ArrayLenForIP = 8 LowPosition = 8 HighPosition = 16 IPV6Prefix = "::ffff:" IPBytesCut = 15 // 15 bytes (120 bits) )
Variables ¶
var ( ErrWrongEncodeType = errors.New("error wrong encode type") ErrWrongDecodeType = errors.New("error wrong decode type") )
All kind of errors
Functions ¶
func BigIntToIPv6 ¶
BigIntToIPv6 converts IP address of version 6 from big integer to net.IP representation.
func DecodeBuffer ¶
DecodeBuffer decode to buffer
func DecodeDecodable ¶
DecodeDecodable decode specific structure
func DecodeFloat32 ¶
DecodeFloat32 decode to float32
func DecodeFloat64 ¶
DecodeFloat64 decode to float64
func EncodeBuffer ¶
EncodeBuffer encode buffer
func EncodeEncodeable ¶
func EncodeEncodeable(v Encodeable, buffer *bytes.Buffer)
EncodeEncodeable encode Encodeable
func EncodeFloat32 ¶
EncodeFloat32 encode float32
func EncodeFloat64 ¶
EncodeFloat64 encode float64
func IPV4ToIPV6 ¶
func IPV6ToString ¶
func IPv6ToBigInt ¶
IPv6ToBigInt converts IP address of version 6 from net.IP to math big integer representation.
func IPv6ToInt ¶
IPv6ToInt converts IP address of version 6 from net.IP to uint64 array representation. Return value contains high integer value on the first place and low integer value on second place.
func IntToIPv6 ¶
IntToIPv6 converts IP address of version 6 from integer (high and low value) to net.IP representation.
func MergeStruct ¶
func MergeStruct(record1 interface{}, record2 interface{}) error
MergeStruct help to fill all existing fields of record1 by record2
Types ¶
type BinaryDecoder ¶
type BinaryDecoder struct {
// contains filtered or unexported fields
}
BinaryDecoder contains buffer and convert binary to value
func NewBinaryDecoder ¶
func NewBinaryDecoder(data []byte) *BinaryDecoder
NewBinaryDecoder return new decoder
func (*BinaryDecoder) Decode ¶
func (b *BinaryDecoder) Decode(value any) error
Decode read value to bytes
type BinaryEncoder ¶
type BinaryEncoder struct {
// contains filtered or unexported fields
}
BinaryEncoder contains buffer and convert values to binary
func (*BinaryEncoder) Encode ¶
func (b *BinaryEncoder) Encode(value any) error
Encode add value to bytes
type Encodeable ¶
Encodeable describe encodeable interface