當前位置: 首頁>>代碼示例>>Golang>>正文


Golang strconv.AppendUint函數代碼示例

本文整理匯總了Golang中strconv.AppendUint函數的典型用法代碼示例。如果您正苦於以下問題:Golang AppendUint函數的具體用法?Golang AppendUint怎麽用?Golang AppendUint使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AppendUint函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: store

func (mc *Connection) store(command, key string, flags uint16, timeout uint64, value []byte, cas uint64) (stored bool) {
	if len(value) > 1000000 {
		return false
	}

	mc.setDeadline()
	// <command name> <key> <flags> <exptime> <bytes> [noreply]\r\n
	mc.writestrings(command, " ", key, " ")
	mc.write(strconv.AppendUint(nil, uint64(flags), 10))
	mc.writestring(" ")
	mc.write(strconv.AppendUint(nil, timeout, 10))
	mc.writestring(" ")
	mc.write(strconv.AppendInt(nil, int64(len(value)), 10))
	if cas != 0 {
		mc.writestring(" ")
		mc.write(strconv.AppendUint(nil, cas, 10))
	}
	mc.writestring("\r\n")
	// <data block>\r\n
	mc.write(value)
	mc.writestring("\r\n")
	reply := mc.readline()
	if strings.Contains(reply, "ERROR") {
		panic(NewError("Server error"))
	}
	return strings.HasPrefix(reply, "STORED")
}
開發者ID:CowLeo,項目名稱:vitess,代碼行數:27,代碼來源:memcache.go

示例2: formatTextValue

func formatTextValue(value interface{}) ([]byte, error) {
	switch v := value.(type) {
	case int8:
		return strconv.AppendInt(nil, int64(v), 10), nil
	case int16:
		return strconv.AppendInt(nil, int64(v), 10), nil
	case int32:
		return strconv.AppendInt(nil, int64(v), 10), nil
	case int64:
		return strconv.AppendInt(nil, int64(v), 10), nil
	case int:
		return strconv.AppendInt(nil, int64(v), 10), nil
	case uint8:
		return strconv.AppendUint(nil, uint64(v), 10), nil
	case uint16:
		return strconv.AppendUint(nil, uint64(v), 10), nil
	case uint32:
		return strconv.AppendUint(nil, uint64(v), 10), nil
	case uint64:
		return strconv.AppendUint(nil, uint64(v), 10), nil
	case uint:
		return strconv.AppendUint(nil, uint64(v), 10), nil
	case float32:
		return strconv.AppendFloat(nil, float64(v), 'f', -1, 64), nil
	case float64:
		return strconv.AppendFloat(nil, float64(v), 'f', -1, 64), nil
	case []byte:
		return v, nil
	case string:
		return hack.Slice(v), nil
	default:
		return nil, errors.Errorf("invalid type %T", value)
	}
}
開發者ID:ZhiephieCook,項目名稱:gh-ost,代碼行數:34,代碼來源:resultset_helper.go

示例3: write_cursor

func write_cursor(x, y int) {
	outbuf.WriteString("\033[")
	outbuf.Write(strconv.AppendUint(intbuf, uint64(y+1), 10))
	outbuf.WriteString(";")
	outbuf.Write(strconv.AppendUint(intbuf, uint64(x+1), 10))
	outbuf.WriteString("H")
}
開發者ID:rrudduck,項目名稱:golang-stuff,代碼行數:7,代碼來源:termbox.go

示例4: String

// Version to string
func (v Version) String() string {
	b := make([]byte, 0, 5)
	b = strconv.AppendUint(b, v.Major, 10)
	b = append(b, '.')
	b = strconv.AppendUint(b, v.Minor, 10)
	b = append(b, '.')
	b = strconv.AppendUint(b, v.Patch, 10)

	if len(v.Pre) > 0 {
		b = append(b, '-')
		b = append(b, v.Pre[0].String()...)

		for _, pre := range v.Pre[1:] {
			b = append(b, '.')
			b = append(b, pre.String()...)
		}
	}

	if len(v.Build) > 0 {
		b = append(b, '+')
		b = append(b, v.Build[0]...)

		for _, build := range v.Build[1:] {
			b = append(b, '.')
			b = append(b, build...)
		}
	}

	return string(b)
}
開發者ID:rupakg,項目名稱:zodiac,代碼行數:31,代碼來源:semver.go

示例5: write_sgr

func write_sgr(fg, bg Attribute) {
	outbuf.WriteString("\033[3")
	outbuf.Write(strconv.AppendUint(intbuf, uint64(fg-1), 10))
	outbuf.WriteString(";4")
	outbuf.Write(strconv.AppendUint(intbuf, uint64(bg-1), 10))
	outbuf.WriteString("m")
}
開發者ID:rrudduck,項目名稱:golang-stuff,代碼行數:7,代碼來源:termbox.go

示例6: appendNumber

func (s *testFlusherSink) appendNumber(v interface{}) {
	switch n := v.(type) {
	case int:
		s.buf = strconv.AppendInt(s.buf, int64(n), 10)
	case uint:
		s.buf = strconv.AppendUint(s.buf, uint64(n), 10)
	case int64:
		s.buf = strconv.AppendInt(s.buf, n, 10)
	case uint64:
		s.buf = strconv.AppendUint(s.buf, n, 10)
	case int32:
		s.buf = strconv.AppendInt(s.buf, int64(n), 10)
	case uint32:
		s.buf = strconv.AppendUint(s.buf, uint64(n), 10)
	case int16:
		s.buf = strconv.AppendInt(s.buf, int64(n), 10)
	case uint16:
		s.buf = strconv.AppendUint(s.buf, uint64(n), 10)
	case int8:
		s.buf = strconv.AppendInt(s.buf, int64(n), 10)
	case uint8:
		s.buf = strconv.AppendUint(s.buf, uint64(n), 10)
	case float64:
		s.buf = strconv.AppendFloat(s.buf, n, 'f', -1, 64)
	case float32:
		s.buf = strconv.AppendFloat(s.buf, float64(n), 'f', -1, 32)
	}
}
開發者ID:One-com,項目名稱:gonelog,代碼行數:28,代碼來源:testsink.go

示例7: Bytes

// Bytes formats the message in a RFC5424 format.
func (msg *Message) Bytes() []byte {
	var b []byte

	// Format priority: <pri>, e.g. <0>, <191>
	b = append(b, priorityStart)
	b = strconv.AppendUint(b, uint64(msg.Priority), 10)
	b = append(b, priorityEnd)

	// Add optional version and a space, e.g. 1, 10
	if msg.Version != 0 {
		b = strconv.AppendUint(b, uint64(msg.Version), 10)
	}
	b = append(b, spaceByte)

	// Add values, with a nil value for a zero value.
	b = addTimestamp(b, msg.Timestamp)
	b = addValue(b, msg.Hostname)
	b = addValue(b, msg.Appname)
	b = addValue(b, msg.ProcessID)
	b = addValue(b, msg.MessageID)

	b = addData(b, msg.Data)

	if msg.Message != "" {
		b = append(b, spaceByte)
		b = append(b, msg.Message...)
	}

	return b
}
開發者ID:Thomasdezeeuw,項目名稱:syslog,代碼行數:31,代碼來源:syslog.go

示例8: appendNumber

func (c *conn) appendNumber(v interface{}) {
	switch n := v.(type) {
	case int:
		c.buf = strconv.AppendInt(c.buf, int64(n), 10)
	case uint:
		c.buf = strconv.AppendUint(c.buf, uint64(n), 10)
	case int64:
		c.buf = strconv.AppendInt(c.buf, n, 10)
	case uint64:
		c.buf = strconv.AppendUint(c.buf, n, 10)
	case int32:
		c.buf = strconv.AppendInt(c.buf, int64(n), 10)
	case uint32:
		c.buf = strconv.AppendUint(c.buf, uint64(n), 10)
	case int16:
		c.buf = strconv.AppendInt(c.buf, int64(n), 10)
	case uint16:
		c.buf = strconv.AppendUint(c.buf, uint64(n), 10)
	case int8:
		c.buf = strconv.AppendInt(c.buf, int64(n), 10)
	case uint8:
		c.buf = strconv.AppendUint(c.buf, uint64(n), 10)
	case float64:
		c.buf = strconv.AppendFloat(c.buf, n, 'f', -1, 64)
	case float32:
		c.buf = strconv.AppendFloat(c.buf, float64(n), 'f', -1, 32)
	}
}
開發者ID:alexcesaro,項目名稱:statsd,代碼行數:28,代碼來源:conn.go

示例9: BuildValue

func BuildValue(goval interface{}) (v Value, err error) {
	switch bindVal := goval.(type) {
	case nil:
		// no op
	case int:
		v = Value{Numeric(strconv.AppendInt(nil, int64(bindVal), 10))}
	case int32:
		v = Value{Numeric(strconv.AppendInt(nil, int64(bindVal), 10))}
	case int64:
		v = Value{Numeric(strconv.AppendInt(nil, int64(bindVal), 10))}
	case uint:
		v = Value{Numeric(strconv.AppendUint(nil, uint64(bindVal), 10))}
	case uint32:
		v = Value{Numeric(strconv.AppendUint(nil, uint64(bindVal), 10))}
	case uint64:
		v = Value{Numeric(strconv.AppendUint(nil, uint64(bindVal), 10))}
	case float64:
		v = Value{Fractional(strconv.AppendFloat(nil, bindVal, 'f', -1, 64))}
	case string:
		v = Value{String([]byte(bindVal))}
	case []byte:
		v = Value{String(bindVal)}
	case time.Time:
		v = Value{String([]byte(bindVal.Format("'2006-01-02 15:04:05'")))}
	case Numeric, Fractional, String:
		v = Value{bindVal.(InnerValue)}
	case Value:
		v = bindVal
	default:
		return Value{}, fmt.Errorf("Unsupported bind variable type %T: %v", goval, goval)
	}
	return v, nil
}
開發者ID:rjammala,項目名稱:vitess,代碼行數:33,代碼來源:sqltypes.go

示例10: writeStoreCommand

func (c *conn) writeStoreCommand(cmd, key string, value []byte, flags uint32, timeout int32, cas uint64) (err error) {
	if len(value) > 1000000 {
		return protocolError("max value size, greate than 1mb")
	}
	// <command name> <key> <flags> <exptime> <bytes> [noreply]\r\n
	c.bw.WriteString(cmd)
	c.bw.WriteByte(space)

	c.bw.WriteString(key)
	c.bw.WriteByte(space)

	c.bw.Write(strconv.AppendUint(c.numScratch[:0], uint64(flags), 10))
	c.bw.WriteByte(space)

	c.bw.Write(strconv.AppendInt(c.numScratch[:0], int64(timeout), 10))
	c.bw.WriteByte(space)

	c.bw.Write(strconv.AppendInt(c.numScratch[:0], int64(len(value)), 10))
	if cas != 0 {
		c.bw.WriteByte(space)
		c.bw.Write(strconv.AppendUint(c.numScratch[:0], cas, 10))
	}
	c.bw.Write(crlf)
	// <data block>\r\n
	c.bw.Write(value)
	_, err = c.bw.Write(crlf)
	return
}
開發者ID:hiproz,項目名稱:gomemcache,代碼行數:28,代碼來源:conn.go

示例11: encodeDefault

func encodeDefault(object interface{}) (buffer []byte, err error) {
	switch object.(type) {
	case bool:
		buffer = strconv.AppendBool(buffer, object.(bool))
	case int:
		buffer = strconv.AppendInt(buffer, int64(object.(int)), _NUMERIC_BASE)
	case int8:
		buffer = strconv.AppendInt(buffer, int64(object.(int8)), _NUMERIC_BASE)
	case int16:
		buffer = strconv.AppendInt(buffer, int64(object.(int16)), _NUMERIC_BASE)
	case int32:
		buffer = strconv.AppendInt(buffer, int64(object.(int32)), _NUMERIC_BASE)
	case int64:
		buffer = strconv.AppendInt(buffer, object.(int64), _NUMERIC_BASE)
	case uint:
		buffer = strconv.AppendUint(buffer, uint64(object.(uint)), _NUMERIC_BASE)
	case uint8:
		buffer = strconv.AppendUint(buffer, uint64(object.(uint8)), _NUMERIC_BASE)
	case uint16:
		buffer = strconv.AppendUint(buffer, uint64(object.(uint16)), _NUMERIC_BASE)
	case uint32:
		buffer = strconv.AppendUint(buffer, uint64(object.(uint32)), _NUMERIC_BASE)
	case uint64:
		buffer = strconv.AppendUint(buffer, object.(uint64), _NUMERIC_BASE)
	case string:
		buffer = []byte(object.(string))
	case []byte:
		buffer = object.([]byte)
	default:
		err = errors.New("Invalid object for default encode")
	}
	return
}
開發者ID:varstr,項目名稱:gomc,代碼行數:33,代碼來源:encoding.go

示例12: String

func (p Percent) String() string {
	var buf [12]byte
	b := strconv.AppendUint(buf[:0], uint64(p)/1000, 10)
	n := len(b)
	b = strconv.AppendUint(b, 1000+uint64(p)%1000, 10)
	b[n] = '.'
	return string(append(b, '%'))
}
開發者ID:xtfly,項目名稱:gofd,代碼行數:8,代碼來源:utils.go

示例13: Pos

func (t TermVT100) Pos(b []byte, x, y int) []byte {
	b = b[:0]
	b = append(b, 27, '[')
	b = strconv.AppendUint(b, uint64(y), 10)
	b = append(b, ';')
	b = strconv.AppendUint(b, uint64(x), 10)
	b = append(b, 'f')
	return b
}
開發者ID:PieterD,項目名稱:crap,代碼行數:9,代碼來源:type_vt100.go

示例14: main

func main() {
	b10 := []byte("uint (base 10):")
	b10 = strconv.AppendUint(b10, 42, 10)
	fmt.Println(string(b10))

	b16 := []byte("uint (base 16):")
	b16 = strconv.AppendUint(b16, 42, 16)
	fmt.Println(string(b16))
}
開發者ID:cwen-coder,項目名稱:study-gopkg,代碼行數:9,代碼來源:AppendUint.go

示例15: EncodeUint

func (e *jsonEncDriver) EncodeUint(v uint64) {
	if x := e.h.IntegerAsString; x == 'A' || x == 'L' && v > 1<<53 {
		e.w.writen1('"')
		e.w.writeb(strconv.AppendUint(e.b[:0], v, 10))
		e.w.writen1('"')
		return
	}
	e.w.writeb(strconv.AppendUint(e.b[:0], v, 10))
}
開發者ID:RichardKnop,項目名稱:example-api,代碼行數:9,代碼來源:json.go


注:本文中的strconv.AppendUint函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。