When I write an array of byte to a binary file I get an extra byte '6F' at the end. Why is that and how do I get rid of that?
package main
import "os"
import "fmt"
func main() {
ff, _ := os.OpenFile("output", os.O_WRONLY|os.O_CREATE, 0)
defer ff.Close()
a := []byte{0x1, 0x2, 0x3, 0x4}
x, y := ff.Write(a)
fmt.Printf("%v %v", x, y)
}
This prints
4 <nil>as expected. But the file has 5 bytes and 'od -tx1 output' tells me this:
0000000 01 02 03 04 6fI though it might have something to do with windows-type text mode adding a newline, but 6F is a lowercase ASCII 'o'...
Stefan