Standard library / encoding/binary

encoding/binary.ByteOrder

Interface for reading and writing unsigned 16-, 32- and 64-bit values. The slice must be long enough. Expected stdout: '258\n'.

Formal Syntax & Structure

go syntaxgo
type ByteOrder interface {  Uint16([]byte) uint16  Uint32([]byte) uint32  Uint64([]byte) uint64  PutUint16([]byte, uint16)  PutUint32([]byte, uint32)  PutUint64([]byte, uint64)  String() string}

Working Example

Example Snippetgo
package main
import (  "encoding/binary"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  var order binary.ByteOrder = binary.LittleEndian  fmt.Println(order.Uint16([]byte{2, 1}))}
Go Reference