package main
import (
"bytes"
"encoding/binary"
"fmt"
)
func main() {
buf1 := new(bytes.Buffer)
err := binary.Write(buf1, binary.LittleEndian, int32(0x41101503))
if err != nil {
fmt.Println("binary.Write failed:", err)
}
// fmt.Printf("%# s\n", buf1)
fmt.Printf("0x%x\n", buf1)
fmt.Printf("0x%X\n", buf1)
}
Ref
- 《Black Hat Go: Go Programming For Hackers and Pentesters》