Skip to content

Instantly share code, notes, and snippets.

@wisecsj
Created March 20, 2021 09:43
Show Gist options
  • Save wisecsj/b5782e6f930bb614348f78dce10e3dd2 to your computer and use it in GitHub Desktop.
Save wisecsj/b5782e6f930bb614348f78dce10e3dd2 to your computer and use it in GitHub Desktop.
判断大端序or小端序
package main
import (
"fmt"
"unsafe"
)
func getbyteorder() {
var n uint16
n = 0x0102
fmt.Println(n)
ptr := unsafe.Pointer(&n)
newptr := (*byte)(ptr)
fmt.Println(*newptr)
}
func main() {
getbyteorder()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment