Standard library / encoding/binary

encoding/binary.LittleEndian

Least significant byte first. Specify when required by the file format. Expected stdout: '0201\n'.

Formal Syntax & Structure

go syntaxgo
var LittleEndian littleEndian

Working Example

Example Snippetgo
package main
import (  "encoding/binary"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() { p := make([]byte, 2); binary.LittleEndian.PutUint16(p, 258); fmt.Printf("%x\n", p) }
Go Reference