public class StructureHelper { public static byte[] StructToBytes(object structObj) { int size = Marshal.SizeOf(structObj); IntPtr buffer = Marshal.Al
Golang 结构体转字节数组(struct to []byte) 代码:package main import ( "bytes" "encoding/binary" "fmt" log "fmt" ) type NCPTargetVersion struct { NCPVersion uint16 SoftwareVersion uint16 HardwareVersion uint16 } func main() { log.Println("create dfu file") // context, err := ioutil....