Created
February 22, 2019 08:06
-
-
Save islishude/cf004e35f632116a784edbc8233e9815 to your computer and use it in GitHub Desktop.
transfer big endian interge to little endian interge by go
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 ( | |
"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