How to read a binary file in Go

后端 未结 4 1807
渐次进展
渐次进展 2020-12-15 17:25

I\'m completely new to Go and I\'m trying to read a binary file, either byte by byte or several bytes at a time. The documentation doesn\'t help much and I cannot find any t

4条回答
  •  悲哀的现实
    2020-12-15 18:19

    You can't whimsically cast primitive types to (char*) like in C, so for any sort of (de)serializing of binary data use the encoding/binary package. http://golang.org/pkg/encoding/binary . I can't improve on the examples there.

提交回复
热议问题