code: func (c *Client) flushLocked() error {
  	frames, flushable := c.joinMaxSize(c.commands, "\n", OptimalPayloadSize)
  	var err error
  	cmdsFlushed := 0
  	for i, data := range frames {
  		_, e := c.writer.Write(data)
  		if e != nil {
  			err = e
  			break
  		}
  		cmdsFlushed += flushable[i]
  	}
  
  	// clear the slice with a slice op, doesn't realloc
  	if cmdsFlushed == len(c.commands) {
  		c.commands = c.commands[:0]
  	} else {
  		//this case will cause a future realloc...
  		// drop problematic command though (sorry).
  		c.commands = c.commands[cmdsFlushed+1:]
  	}
  	return err
  }
docs: // flush the commands in the buffer.  Lock must be held by caller.