About binary files

There is no difference between reading and writing binary and plain text files in Go. So, when processing a file, Go makes no assumptions about its format. However, Go offers a package named binary that allows you to make translations between different encodings such as little endian and big endian.

The readBinary.go file briefly illustrates how to convert an integer number to a little endian number and to a big endian number, which might be useful when the files you want to process contain certain kinds of data; this mainly happens when we are dealing with raw devices and raw packet manipulation: remember everything is a file! The source code of readBinary.go will be presented in two parts.

The first part is as follows: ...

Get Go Systems Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.