将curl命令转换为golang conn.publish代码

I am trying to talk to server via Golang and I am unable to get it to work:

However, the following CURL Command works:

"curl http://localhost:8888/auth"

I know the form is:

<subject> <payload length> "
" <payload>

but everything I try fails.

The publish code is as follows:

// Publish takes a subject as an immutable string and payload inbytes,
// then sends the message to the server.

func (c *Client) Publish(subject string, payload []byte) error {
    c.Lock()
    pub := fmt.Sprintf("%s %d
", subject, len(payload))
    _, err := c.w.WriteString(pub)

    if err == nil {
        _, err = c.w.Write(payload)
    }
    if err == nil {
        _, err = c.w.WriteString("
")
    }
    if err == nil {
        err = c.w.Flush()
    }
    c.Unlock()
    if err != nil {
        return err
    }

    return nil
}

I would appreciate any help that can be offered.