当前位置: 首页>>代码示例>>Golang>>正文


Golang strconv.Atoui64函数代码示例

本文整理汇总了Golang中strconv.Atoui64函数的典型用法代码示例。如果您正苦于以下问题:Golang Atoui64函数的具体用法?Golang Atoui64怎么用?Golang Atoui64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Atoui64函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: parse

/* parse a storage command parameters and read the related data
   returns a flag indicating sucesss */
func (self *StorageCommand) parse(line []string) bool {
	var flags, exptime, bytes, casuniq uint64
	var err os.Error
	if len(line) < 5 {
		return Error(self.session, ClientError, "Bad storage command: missing parameters")
	} else if flags, err = strconv.Atoui64(line[2]); err != nil {
		return Error(self.session, ClientError, "Bad storage command: bad flags")
	} else if exptime, err = strconv.Atoui64(line[3]); err != nil {
		return Error(self.session, ClientError, "Bad storage command: bad expiration time")
	} else if bytes, err = strconv.Atoui64(line[4]); err != nil {
		return Error(self.session, ClientError, "Bad storage command: bad byte-length")
	} else if line[0] == "cas" {
		if casuniq, err = strconv.Atoui64(line[5]); err != nil {
			return Error(self.session, ClientError, "Bad storage command: bad cas value")
		}
	}
	self.command = line[0]
	self.key = line[1]
	self.flags = uint32(flags)
	if exptime == 0 || exptime > secondsInMonth {
		self.exptime = uint32(exptime)
	} else {
		self.exptime = uint32(time.Seconds()) + uint32(exptime)
	}
	self.bytes = uint32(bytes)
	self.cas_unique = casuniq
	if line[len(line)-1] == "noreply" {
		self.noreply = true
	}
	return self.readData()
}
开发者ID:rdarder,项目名称:gocached,代码行数:33,代码来源:command.go

示例2: Incr

func (self *MapCacheStorage) Incr(key string, value uint64, incr bool) (ErrorCode, *StorageEntry, *StorageEntry) {
	self.rwLock.Lock()
	defer self.rwLock.Unlock()
	entry, present := self.storageMap[key]
	if present && !entry.expired() {
		if addValue, err := strconv.Atoui64(string(entry.content)); err == nil {
			var incrValue uint64
			if incr {
				incrValue = uint64(addValue) + value
			} else if value > addValue {
				incrValue = 0
			} else {
				incrValue = uint64(addValue) - value
			}
			incrStrValue := strconv.Uitoa64(incrValue)
			old_value := entry.content
			entry.content = []byte(incrStrValue)
			entry.bytes = uint32(len(entry.content))
			entry.cas_unique += 1
			return Ok, &StorageEntry{entry.exptime, entry.flags, entry.bytes, entry.cas_unique, old_value}, entry
		} else {
			return IllegalParameter, nil, nil
		}
	}
	return KeyNotFound, nil, nil
}
开发者ID:rdarder,项目名称:gocached,代码行数:26,代码来源:mapcachestorage.go

示例3: U64

// Get node value as uint64
func (this *Node) U64(namespace, name string) uint64 {
	if node := rec_SelectNode(this, namespace, name); node != nil && node.Value != "" {
		n, _ := strconv.Atoui64(node.Value)
		return n
	}
	return 0
}
开发者ID:dustywilson,项目名称:go-pkg-xmlx,代码行数:8,代码来源:node.go

示例4: Au64

// Get attribute value as uint64
func (this *Node) Au64(namespace, name string) uint64 {
	if s := this.As(namespace, name); s != "" {
		n, _ := strconv.Atoui64(s)
		return n
	}
	return 0
}
开发者ID:dustywilson,项目名称:go-pkg-xmlx,代码行数:8,代码来源:node.go

示例5: checkForInt

func (r result) checkForInt(c *Conn, s string) (uint64, os.Error) {
	if r.err != nil {
		return 0, Error{c.Name, r.cmd, r.line, r.err}
	}

	if err, ok := replyErrors[r.name]; ok {
		return 0, Error{c.Name, r.cmd, r.line, err}
	}

	if r.name != s {
		return 0, Error{c.Name, r.cmd, r.line, BadReply}
	}

	if len(r.args) != 1 {
		return 0, Error{c.Name, r.cmd, r.line, BadReply}
	}

	n, err := strconv.Atoui64(r.args[0])

	if err != nil {
		return 0, Error{c.Name, r.cmd, r.line, BadReply}
	}

	return n, nil
}
开发者ID:schmichael,项目名称:beanstalk.go,代码行数:25,代码来源:beanstalk.go

示例6: AsUint64

func AsUint64(v interface{}) (uint64, os.Error) {
	switch value := v.(type) {
	default:
		return 0, os.NewError(fmt.Sprintf("unexpected type: %T", value))
	case int:
		return uint64(value), nil
	case int8:
		return uint64(value), nil
	case int16:
		return uint64(value), nil
	case int32:
		return uint64(value), nil
	case int64:
		return uint64(value), nil
	case uint:
		return uint64(value), nil
	case uint8:
		return uint64(value), nil
	case uint16:
		return uint64(value), nil
	case uint32:
		return uint64(value), nil
	case uint64:
		return value, nil
	case float32:
		return uint64(value), nil
	case float64:
		return uint64(value), nil
	case string:
		return strconv.Atoui64(value)
	}
	panic(fmt.Sprintf("unsupported type: %s", reflect.ValueOf(v).Type().Name()))
}
开发者ID:thomaslee,项目名称:go-ext,代码行数:33,代码来源:conversions.go

示例7: checkForJob

func (r result) checkForJob(c *Conn, s string) (*Job, os.Error) {
	if r.err != nil {
		return nil, Error{c.Name, r.cmd, r.line, r.err}
	}

	if err, ok := replyErrors[r.name]; ok {
		return nil, Error{c.Name, r.cmd, r.line, err}
	}

	if r.name != s {
		return nil, Error{c.Name, r.cmd, r.line, BadReply}
	}

	if len(r.args) != 2 {
		return nil, Error{c.Name, r.cmd, r.line, BadReply}
	}

	id, err := strconv.Atoui64(r.args[0])

	if err != nil {
		return nil, Error{c.Name, r.cmd, r.line, BadReply}
	}

	return &Job{id, r.body, c}, nil
}
开发者ID:schmichael,项目名称:beanstalk.go,代码行数:25,代码来源:beanstalk.go

示例8: decodeColumn

func decodeColumn(idx int, field *mysql.Field, val interface{}) (interface{}, os.Error) {
	var dec interface{}
	var err os.Error
	switch v := val.(type) {
	case int64:
		return v, nil
	case []byte:
		switch field.Type {
		case mysql.FIELD_TYPE_TINY, mysql.FIELD_TYPE_SHORT, mysql.FIELD_TYPE_YEAR, mysql.FIELD_TYPE_INT24, mysql.FIELD_TYPE_LONG, mysql.FIELD_TYPE_LONGLONG:
			if field.Flags&mysql.FLAG_UNSIGNED != 0 {
				dec, err = strconv.Atoui64(string(v))
			} else {
				dec, err = strconv.Atoi64(string(v))
			}
			if err != nil {
				return nil, fmt.Errorf("mysql: strconv.Atoi64 error on field %d: %v", idx, err)
			}
		case mysql.FIELD_TYPE_FLOAT, mysql.FIELD_TYPE_DOUBLE:
			dec, err = strconv.Atof64(string(v))
			if err != nil {
				return nil, fmt.Errorf("mysql: strconv.Atof64 error on field %d: %v", idx, err)
			}
		case mysql.FIELD_TYPE_DECIMAL, mysql.FIELD_TYPE_NEWDECIMAL, mysql.FIELD_TYPE_VARCHAR, mysql.FIELD_TYPE_VAR_STRING, mysql.FIELD_TYPE_STRING:
			dec = string(v)
		default:
			return nil, fmt.Errorf("row[%d] was a []byte but unexpected field type %d", idx, field.Type)
		}
		return dec, nil
	}
	return nil, fmt.Errorf("expected row[%d] contents to be a []byte, got %T for field type %d", idx, val, field.Type)
}
开发者ID:ipeet,项目名称:camlistore,代码行数:31,代码来源:mywrap.go

示例9: getIDFromIDFile

func getIDFromIDFile() (uint64, os.Error) {
	G_idServerLock.Lock()
	defer G_idServerLock.Unlock()
	fd, err := os.Open(IDFILE, os.O_RDONLY, 0666)
	if err == nil {
		buf := bufio.NewReader(fd)
		lineofbytes, errb := buf.ReadBytes('\n')
		if errb == nil {
			lineofbytes = TrimCRLF(lineofbytes)
			fd.Close()
			return strconv.Atoui64(string(lineofbytes))
		} else {
			fmt.Println("Error creating bufio.NewReader(fd)")
		}
	} else {
		// Error reading file, does it exist?
		stat, _ := os.Stat(IDFILE)
		if stat == nil {
			// File doesn't exist
			fmt.Println("id.txt doesn't exist... Create one...")
			createNewIDFile()
		} else {
			fmt.Println("Can't open id.txt, but it does exist... FATAL.")
			os.Exit(-2)
		}
		return 0, nil
	}

	return 0, os.NewError("Impossible")
}
开发者ID:GoogleSourceExpoted,项目名称:goesmtp,代码行数:30,代码来源:idserver.go

示例10: U64

func (this ParamList) U64(i int, defval uint64) uint64 {
	if -1 < i && i < len(this) {
		if v, err := strconv.Atoui64(this[i]); err == nil {
			return v
		}
	}
	return defval
}
开发者ID:welterde,项目名称:mudkip,代码行数:8,代码来源:params.go

示例11: U64

func (this *Section) U64(key string, defval uint64) uint64 {
	if v, ok := this.Pairs[key]; ok {
		if n, err := strconv.Atoui64(v); err == nil {
			return n
		}
	}
	return defval
}
开发者ID:welterde,项目名称:go-pkg-ini,代码行数:8,代码来源:section.go

示例12: Euler43

func Euler43() string {
	sum := uint64(0)
	pand := []byte("1023456789")
	for arithmetics.Permute(pand) {
		hasProperty := true
		for i, prime := range smallprimes {
			num, _ := strconv.Atoui64(string(pand[1+i : 4+i]))
			if num%prime != 0 {
				hasProperty = false
				break
			}
		}
		if hasProperty {
			num, _ := strconv.Atoui64(string(pand))
			sum += num
		}
	}
	return fmt.Sprint(sum)
}
开发者ID:Narsil,项目名称:go-euler,代码行数:19,代码来源:problem43.go

示例13: prepare

func (self *Coder) prepare() {
	if self.Ctx == nil {
		self.Ctx = C.avcodec_alloc_context()
		cid, _ := strconv.Atoui64(self.Parameter["codecid"])
		self.Ctx.codec_id = uint32(cid)
	}
	/**
	 * @TODO: settng the fixed params like width, height, channels...
	 */
}
开发者ID:psychobob666,项目名称:MediaEncodingCluster,代码行数:10,代码来源:ffmpeg.go

示例14: update

func (cl *cleaner) update(ev store.Event) {
	parts := strings.Split(ev.Path, "/", -1)
	id := parts[3]
	seqn, err := strconv.Atoui64(ev.Body)
	if err != nil {
		cl.logger.Println(err)
		return
	}
	cl.table[id] = seqn
}
开发者ID:andradeandrey,项目名称:doozer,代码行数:10,代码来源:clean.go

示例15: copyValue

func copyValue(dst reflect.Value, src []byte) (err os.Error) {
	// Helper functions for integer and unsigned integer conversions
	var itmp int64
	getInt64 := func() bool {
		itmp, err = strconv.Atoi64(string(src))
		// TODO: should check sizes
		return err == nil
	}
	var utmp uint64
	getUint64 := func() bool {
		utmp, err = strconv.Atoui64(string(src))
		// TODO: check for overflow?
		return err == nil
	}
	var ftmp float64
	getFloat64 := func() bool {
		ftmp, err = strconv.Atof64(string(src))
		// TODO: check for overflow?
		return err == nil
	}

	// Save accumulated data and comments
	switch t := dst; t.Kind() {
	case reflect.Invalid:
		// Probably a comment, handled below
	default:
		return os.NewError("cannot happen: unknown type " + t.Type().String())
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		if !getInt64() {
			return err
		}
		t.SetInt(itmp)
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		if !getUint64() {
			return err
		}
		t.SetUint(utmp)
	case reflect.Float32, reflect.Float64:
		if !getFloat64() {
			return err
		}
		t.SetFloat(ftmp)
	case reflect.Bool:
		value, err := strconv.Atob(strings.TrimSpace(string(src)))
		if err != nil {
			return err
		}
		t.SetBool(value)
	case reflect.String:
		t.SetString(string(src))
	case reflect.Slice:
		t.Set(reflect.ValueOf(src))
	}
	return nil
}
开发者ID:Quantumboost,项目名称:gcc,代码行数:55,代码来源:read.go


注:本文中的strconv.Atoui64函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。