Created
March 20, 2021 09:43
-
-
Save wisecsj/b5782e6f930bb614348f78dce10e3dd2 to your computer and use it in GitHub Desktop.
判断大端序or小端序
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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