package byteorder
func LeUint16 (b []byte ) uint16 {
_ = b [1 ]
return uint16 (b [0 ]) | uint16 (b [1 ])<<8
}
func LePutUint16 (b []byte , v uint16 ) {
_ = b [1 ]
b [0 ] = byte (v )
b [1 ] = byte (v >> 8 )
}
func LeAppendUint16 (b []byte , v uint16 ) []byte {
return append (b ,
byte (v ),
byte (v >>8 ),
)
}
func LeUint32 (b []byte ) uint32 {
_ = b [3 ]
return uint32 (b [0 ]) | uint32 (b [1 ])<<8 | uint32 (b [2 ])<<16 | uint32 (b [3 ])<<24
}
func LePutUint32 (b []byte , v uint32 ) {
_ = b [3 ]
b [0 ] = byte (v )
b [1 ] = byte (v >> 8 )
b [2 ] = byte (v >> 16 )
b [3 ] = byte (v >> 24 )
}
func LeAppendUint32 (b []byte , v uint32 ) []byte {
return append (b ,
byte (v ),
byte (v >>8 ),
byte (v >>16 ),
byte (v >>24 ),
)
}
func LeUint64 (b []byte ) uint64 {
_ = b [7 ]
return uint64 (b [0 ]) | uint64 (b [1 ])<<8 | uint64 (b [2 ])<<16 | uint64 (b [3 ])<<24 |
uint64 (b [4 ])<<32 | uint64 (b [5 ])<<40 | uint64 (b [6 ])<<48 | uint64 (b [7 ])<<56
}
func LePutUint64 (b []byte , v uint64 ) {
_ = b [7 ]
b [0 ] = byte (v )
b [1 ] = byte (v >> 8 )
b [2 ] = byte (v >> 16 )
b [3 ] = byte (v >> 24 )
b [4 ] = byte (v >> 32 )
b [5 ] = byte (v >> 40 )
b [6 ] = byte (v >> 48 )
b [7 ] = byte (v >> 56 )
}
func LeAppendUint64 (b []byte , v uint64 ) []byte {
return append (b ,
byte (v ),
byte (v >>8 ),
byte (v >>16 ),
byte (v >>24 ),
byte (v >>32 ),
byte (v >>40 ),
byte (v >>48 ),
byte (v >>56 ),
)
}
func BeUint16 (b []byte ) uint16 {
_ = b [1 ]
return uint16 (b [1 ]) | uint16 (b [0 ])<<8
}
func BePutUint16 (b []byte , v uint16 ) {
_ = b [1 ]
b [0 ] = byte (v >> 8 )
b [1 ] = byte (v )
}
func BeAppendUint16 (b []byte , v uint16 ) []byte {
return append (b ,
byte (v >>8 ),
byte (v ),
)
}
func BeUint32 (b []byte ) uint32 {
_ = b [3 ]
return uint32 (b [3 ]) | uint32 (b [2 ])<<8 | uint32 (b [1 ])<<16 | uint32 (b [0 ])<<24
}
func BePutUint32 (b []byte , v uint32 ) {
_ = b [3 ]
b [0 ] = byte (v >> 24 )
b [1 ] = byte (v >> 16 )
b [2 ] = byte (v >> 8 )
b [3 ] = byte (v )
}
func BeAppendUint32 (b []byte , v uint32 ) []byte {
return append (b ,
byte (v >>24 ),
byte (v >>16 ),
byte (v >>8 ),
byte (v ),
)
}
func BeUint64 (b []byte ) uint64 {
_ = b [7 ]
return uint64 (b [7 ]) | uint64 (b [6 ])<<8 | uint64 (b [5 ])<<16 | uint64 (b [4 ])<<24 |
uint64 (b [3 ])<<32 | uint64 (b [2 ])<<40 | uint64 (b [1 ])<<48 | uint64 (b [0 ])<<56
}
func BePutUint64 (b []byte , v uint64 ) {
_ = b [7 ]
b [0 ] = byte (v >> 56 )
b [1 ] = byte (v >> 48 )
b [2 ] = byte (v >> 40 )
b [3 ] = byte (v >> 32 )
b [4 ] = byte (v >> 24 )
b [5 ] = byte (v >> 16 )
b [6 ] = byte (v >> 8 )
b [7 ] = byte (v )
}
func BeAppendUint64 (b []byte , v uint64 ) []byte {
return append (b ,
byte (v >>56 ),
byte (v >>48 ),
byte (v >>40 ),
byte (v >>32 ),
byte (v >>24 ),
byte (v >>16 ),
byte (v >>8 ),
byte (v ),
)
}
The pages are generated with Golds v0.7.0-preview . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .