Skip to content

Instantly share code, notes, and snippets.

@islishude
Created February 22, 2019 08:06
Show Gist options
  • Save islishude/cf004e35f632116a784edbc8233e9815 to your computer and use it in GitHub Desktop.
Save islishude/cf004e35f632116a784edbc8233e9815 to your computer and use it in GitHub Desktop.
transfer big endian interge to little endian interge by go
package main
import (
"encoding/hex"
"fmt"
)
func main() {
n := 0xffee
result := make([]byte, 0, 2)
for n > 0 {
result = append(result, byte(n&0xff))
n >>= 8
}
fmt.Println(hex.EncodeToString(result))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment