// Send a string or a struct as parameters
554466
func (k *Client) Send(content interface{}) *Client {
	switch v := reflect.ValueOf(content); v.Kind() {
	case reflect.String:
		k.SendString(v.String())
	case reflect.Struct:
		k.SendStruct(v.Interface())
	default:
	}
	return k
}
916487
func (k *Client) SendStruct(content interface{}) *Client {
	if marshalContent, err := json.Marshal(content); err != nil {
		k.Errors = append(k.Errors, err)
	} else {
		var val map[string]interface{}
		d := json.NewDecoder(bytes.NewBuffer(marshalContent))
		d.UseNumber()
		if err := d.Decode(&val); err != nil {
			k.Errors = append(k.Errors, err)
		} else {
			for key, v := range val {
				k.Data[key] = v
			}
		}
	}
	return k
}
1041176
func (c *Client) Send(req *http.Request, v interface{}) error {
	var (
		err  error
		resp *http.Response
		data []byte
	)

	// Set default headers
	req.Header.Set("Accept", "application/json")
	req.Header.Set("Accept-Language", "en_US")

	// Default values for headers
	if req.Header.Get("Content-type") == "" {
		req.Header.Set("Content-type", "application/json")
	}

	resp, err = c.Client.Do(req)
	c.log(req, resp)

	if err != nil {
		return err
	}
	defer resp.Body.Close()

	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		errResp := &ErrorResponse{Response: resp}
		data, err = ioutil.ReadAll(resp.Body)

		if err == nil && len(data) > 0 {
			json.Unmarshal(data, errResp)
		}

		return errResp
	}

	if v == nil {
		return nil
	}

	if w, ok := v.(io.Writer); ok {
		io.Copy(w, resp.Body)
		return nil
	}

	return json.NewDecoder(resp.Body).Decode(v)
}
1004312
func (m *Message) Send(c slack.Client) (*MessageResponse, error) {
	resp := &MessageResponse{}
	if err := c.Send(PostMessageEndpoint, m, resp); err != nil {
		return nil, err
	}

	return resp, nil
}
777594
func (a *adapter) Send(res *hal.Response, strings ...string) error {
	if a.responseMethod == "irc" {
		if !a.ircEnabled {
			return errors.New("slack - IRC response method used but IRC is not enabled")
		}
		a.sendIRC(res, strings...)

	} else {
		err := error(a.sendHTTP(res, strings...))
		if err != nil {
			return err
		}
	}

	return nil
}
354368
func (q *Queue) SendString(method string, rawurl ...string) (int, error) {
	return q.sendWithMethod(method, rawurl)
}
692491
func (c *Conn) Send(commandName string, args ...interface{}) error {
	c.queue = append(c.queue, queueElement{
		commandName: commandName,
		args:        args,
	})
	return nil
}
198848
func (p *conn) Send(msg *Message) error {

	l := uint64(len(msg.Header) + len(msg.Body))

	if msg.Expired() {
		msg.Free()
		return nil
	}

	// send length header
	if err := binary.Write(p.c, binary.BigEndian, l); err != nil {
		return err
	}
	if _, err := p.c.Write(msg.Header); err != nil {
		return err
	}
	// hope this works
	if _, err := p.c.Write(msg.Body); err != nil {
		return err
	}
	msg.Free()
	return nil
}
128441
func (c *Conn) Send(to, msg string) error {
	return c.conn.Send(to, msg)
}
284389
func (kvmsg *Kvmsg) Send(socket *zmq.Socket) (err error) {
	//fmt.Printf("Send to %s: %q\n", socket, kvmsg.frame)
	kvmsg.encode_props()
	_, err = socket.SendMessage(kvmsg.frame)
	return
}
43023
func (c *StatsdClient) send(stat string, format string, value interface{}, sampleRate float32) error {
	if c.conn == nil {
		return errNotConnected
	}

	stat = strings.Replace(stat, "%HOST%", Hostname, 1)
	metricString := c.prefix + stat + ":" + fmt.Sprintf(format, value)

	if sampleRate != 1 {
		metricString = fmt.Sprintf("%s|@%f", metricString, sampleRate)
	}

	// if sending tcp append a newline
	if c.sockType == tcpSocket {
		metricString += "\n"
	}

	_, err := fmt.Fprint(c.conn, metricString)
	return err
}
596379
func (s *Streamer) SendString(id, event, data string) {
	dataLen := len(data)
	lfCount := 0

	// We must sent a "data:{data}\n" for each line
	if dataLen > 0 {
		lfCount = strings.Count(data, "\n")
		if lfCount > 0 {
			dataLen += (5 * lfCount) // data:
		}
	}

	p := format(id, event, dataLen)

	// fill in data lines
	start := 0
	ins := len(p) - (2 + dataLen)
	for i := 0; lfCount > 0; i++ {
		if data[i] == '\n' {
			copy(p[ins:], data[start:i])
			ins += i - start
			copy(p[ins:], "\ndata:")
			ins += 6

			start = i + 1
			lfCount--
		}
	}
	copy(p[ins:], data[start:])

	s.event <- p
}
1006791
func (s *Server) send() error {
	failures := 0
	for {
		err := s.sendBatch(s.batch)
		if err == nil {
			break
		}

		failures++
		log.Errorf("Send failed %d times: %v", failures, err)
		if failures >= s.config.MaxFailures {
			return fmt.Errorf("send: %d errors, giving up", failures)
		}

		time.Sleep(s.config.RetryDelay)
	}

	s.batch = s.batch[:0]
	return nil
}
765745
func (c *Client) Send(message string) error {
	_, err := c.conn.Write([]byte(message))
	return err
}
555957
func (s *SimpleSender) Send(data []byte) (int, error) {
	// no need for locking here, as the underlying fdNet
	// already serialized writes
	n, err := s.c.(*net.UDPConn).WriteToUDP(data, s.ra)
	if err != nil {
		return 0, err
	}
	if n == 0 {
		return n, errors.New("Wrote no bytes")
	}
	return n, nil
}
795462
func (r *reply) send(bv uint64) error {
	type resp struct {
		ReqID, BV uint64
		Data      rlp.RawValue
	}
	return p2p.Send(r.w, r.msgcode, resp{r.reqID, bv, r.data})
}
615124
func (f paramFiller) paramsStructMap(value map[string]interface{}, shape *Shape) string {
	out := f.typeName(shape) + "{\n"
	keys := util.SortedKeys(value)
	for _, k := range keys {
		v := value[k]
		out += fmt.Sprintf("%q: %s,\n", k, f.paramsStructAny(v, shape.ValueRef.Shape))
	}
	out += "}"
	return out
}