client.go
func (h *HAProxyClient) RunCommand(cmd string) (*bytes.Buffer, error) {
	err := h.dial()
	if err != nil {
		return nil, err
	}
	defer h.conn.Close()

	result := bytes.NewBuffer(nil)

	_, err = h.conn.Write([]byte(cmd + "\n"))
	if err != nil {
		return nil, err
	}

	_, err = io.Copy(result, h.conn)
	if err != nil {
		return nil, err
	}

	if strings.HasPrefix(result.String(), "Unknown command") {
		return nil, fmt.Errorf("Unknown command: %s", cmd)
	}

	return result, nil
}
func (h *HAProxyClient) RunCommand(cmd string) (*bytes.Buffer, error) {
	err := h.dial()
	if err != nil {
		return nil, err
	}
	defer h.conn.Close()

	result := bytes.NewBuffer(nil)

	_, err = h.conn.Write([]byte(cmd + "\n"))
	if err != nil {
		return nil, err
	}

	_, err = io.Copy(result, h.conn)
	if err != nil {
		return nil, err
	}

	if strings.HasPrefix(result.String(), "Unknown command") {
		return nil, fmt.Errorf("Unknown command: %s", cmd)
	}

	return result, nil
}
// RunCommand is the entrypoint to the client. Sends an arbitray command string to HAProxy.