当前位置: 首页>>代码示例>>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;未经允许,请勿转载。