使用GO将二进制整数字节写入串行连接

Does this write a 4 (the byte 00000100) to the serial port?

buf := make([]byte, 4)
d, err := connection.Write(buf)

Because it seems like something is getting sent, but my code on the other end that is expecting a 4 does not get triggered. I have other code in another language that sends a 4 to the Arduino, and it responds fine. And I can see the light blink when the above code runs, but it's somehow not he byte I'm expecting.

So how do send the byte 00000100 over the serial port?

Full code here:

package main

import (
  "github.com/tarm/goserial"
  "log"
  "time"
)

func main() {
  config := &serial.Config{Name: "/dev/tty.usbmodem1421", Baud: 9600}
  connection, err := serial.OpenPort(config)
  if err != nil {
    log.Fatal(err)
  }

  // Wait for Arduino
  time.Sleep(5 * time.Second)

  // Send the binary integer 4 to the serial port
  buf := make([]byte, 4)
  _, err = connection.Write(buf)
  if err != nil {
    log.Fatal(err)
  }

  // Wait for Arduino
  time.Sleep(1 * time.Second)

  // Cleanup
  connection.Close()
}

It looks like I totally misunderstood the second argument to make...

buf := make([]byte, 1) // second arg is lenght of array, not a value in the array
binary.PutUvarint(buf, 8) // add my int value to the buffer
connection.Write(buf) // send it!