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


Golang strconv.Itoa64函数代码示例

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


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

示例1: fetchTrackerInfo

func (t *TorrentSession) fetchTrackerInfo(event string) {
	m, si := t.m, t.si
	log.Println("Stats: Uploaded", si.Uploaded, "Downloaded", si.Downloaded, "Left", si.Left)
	// A single concatenation would brake compilation for ARM.
	url := m.Announce + "?" +
		"info_hash=" + http.URLEscape(m.InfoHash) +
		"&peer_id=" + si.PeerId +
		"&port=" + strconv.Itoa(si.Port)
	url += "&uploaded=" + strconv.Itoa64(si.Uploaded) +
		"&downloaded=" + strconv.Itoa64(si.Downloaded) +
		"&left=" + strconv.Itoa64(si.Left) +
		"&compact=1"
	if event != "" {
		url += "&event=" + event
	}
	ch := t.trackerInfoChan
	go func() {
		ti, err := getTrackerInfo(url)
		if ti == nil || err != nil {
			log.Println("Could not fetch tracker info:", err)
		} else {
			ch <- ti
		}
	}()
}
开发者ID:quantumelixir,项目名称:Taipei-Torrent,代码行数:25,代码来源:torrent.go

示例2: SendFile

func SendFile(file *os.File, fileLen int64) bool {
	var laddr = &net.TCPAddr{}
	var raddr = &net.TCPAddr{IP: Server.Nets[0].IP, Port: Server.Port}
	conn, err := net.DialTCP("tcp4", laddr, raddr)
	if err != nil {
		return false
	}
	conn.SetTimeout(2 * SECOND)
	defer conn.Close()

	pkt := make([]byte, MAX_TCP_PKT)
	if !responseServerAuth(conn, pkt) {
		return false
	}

	contentLen := int64(0)
	if fileLen%int64(Cipher.BlockSize()) == 0 {
		contentLen = fileLen
	} else {
		contentLen = (fileLen/int64(Cipher.BlockSize()) + 1) * int64(Cipher.BlockSize())
	}

	pktlen := 0
	pktlen += pktAddHeader(pkt[pktlen:], PACKET_TYPE_TAG, PACKET_TYPE_SEND_FILE)
	pktlen += pktAddHeader(pkt[pktlen:], USERNAME_TAG, Self.Name)
	pktlen += pktAddHeader(pkt[pktlen:], HOSTNAME_TAG, Self.Hostname)
	pktlen += pktAddHeader(pkt[pktlen:], FILE_NAME_TAG, filepath.Base(file.Name()))
	pktlen += pktAddHeader(pkt[pktlen:], CONTENT_LEN_TAG, strconv.Itoa64(contentLen))
	pktlen += pktAddHeader(pkt[pktlen:], PADDING_LEN_TAG, strconv.Itoa64(contentLen-fileLen))
	pktlen += pktAddHeaderEndMark(pkt[pktlen:])

	if writeBuf(conn, pkt[:pktlen]) != pktlen {
		return false
	}
	encrypter := NewCBCEncrypter()
	for {
		if fileLen < int64(cap(pkt)) {
			pkt = pkt[:fileLen]
		} else {
			pkt = pkt[:cap(pkt)]
		}
		if n, _ := fullRead(file, pkt); n != len(pkt) {
			return false
		}
		fileLen -= int64(len(pkt))
		if len(pkt)%Cipher.BlockSize() != 0 {
			//at file end
			n := (len(pkt)/Cipher.BlockSize() + 1) * Cipher.BlockSize()
			pkt = pkt[:n]
		}
		encrypter.CryptBlocks(pkt, pkt)
		if writeBuf(conn, pkt) != len(pkt) {
			return false
		}
		if fileLen <= 0 {
			break
		}
	}
	return true
}
开发者ID:zbq,项目名称:gg,代码行数:60,代码来源:gg.go

示例3: Encode

// Encode writes the Image m to w in PNG format. Any Image may be encoded, but
// images that are not image.NRGBA might be encoded lossily.
func Encode(w io.Writer, m image.Image) os.Error {
	// Obviously, negative widths and heights are invalid. Furthermore, the PNG
	// spec section 11.2.2 says that zero is invalid. Excessively large images are
	// also rejected.
	mw, mh := int64(m.Width()), int64(m.Height())
	if mw <= 0 || mh <= 0 || mw >= 1<<32 || mh >= 1<<32 {
		return FormatError("invalid image size: " + strconv.Itoa64(mw) + "x" + strconv.Itoa64(mw))
	}

	var e encoder
	e.w = w
	e.m = m
	e.colorType = uint8(ctTrueColorAlpha)
	pal, _ := m.(*image.Paletted)
	if pal != nil {
		e.colorType = ctPaletted
	} else if opaque(m) {
		e.colorType = ctTrueColor
	}

	_, e.err = io.WriteString(w, pngHeader)
	e.writeIHDR()
	if pal != nil {
		e.writePLTE(pal.Palette)
	}
	e.writeIDATs()
	e.writeIEND()
	return e.err
}
开发者ID:8l,项目名称:go-learn,代码行数:31,代码来源:writer.go

示例4: main

func main() {
	/*	list, _ := ioutil.ReadDir("/Users/sunfmin/Developments/perapera/templates/videos")

		for _, f := range list {
			fmt.Println(f.Name)
		}
	*/
	ts := templateset.MustBuildFromDirectory("./templates/videos", nil)

	fmt.Println(ts)

	ch := make(chan int, 10)
	ch <- 1
	ch <- 2
	fmt.Println(len(ch))
	fmt.Println(cap(ch))

	fmt.Println(([]int)("Hi Felix"))
	fmt.Println(string([]int{70, 101, 108, 105, 120}))
	fmt.Println(string(1212))
	fmt.Println(strconv.Itoa64(121212312312))
	fmt.Println(strconv.Itoa64(121))

	fmt.Println(MyString("hello cool"))

	fmt.Println(12 << 1)

	fmt.Println(os.Stdout)

	f, _ := os.Open("perapera.go")
	var buf [48]byte

	fmt.Println(buf)

	f.Read(buf[0:32])

	/*	fmt.Println(string([]byte{'1', '2'}))*/
	fmt.Println(string([]byte{112, 97}))
	fmt.Println(string(buf[0:]))

	fmt.Println(cap(buf[0:12]))
	fmt.Println(len(buf[0:12]))

	fmt.Println(os.Stdout)

	fmt.Println(buf)

	a := [...]float64{7.0, 8.5, 9.1, 10, 12}

	fmt.Println(a)

	fmt.Println(&T{"hi"})

	fmt.Println(&[]int{1, 2})

	x := Sum(&[]float64{7.0, 8.5, 9.1, 10, 202})
	fmt.Println(x)
}
开发者ID:sunfmin,项目名称:perapera,代码行数:58,代码来源:perapera_test.go

示例5: createSessionId

func createSessionId(username string) string {
	hm := hmac.NewSHA1([]byte(ServerSecret))
	hm.Write([]byte(username))
	hm.Write([]byte(strconv.Itoa64(sessionIdCounter)))
	hm.Write([]byte(strconv.Itoa64(time.Seconds())))
	sessionIdCounter++
	hex := fmt.Sprintf("%02x", hm.Sum())
	return hex
}
开发者ID:AaronO,项目名称:lightwave,代码行数:9,代码来源:session.go

示例6: baseParams

func (c *Consumer) baseParams(consumerKey string, additionalParams map[string]string) *OrderedParams {
	params := NewOrderedParams()
	params.Add(VERSION_PARAM, OAUTH_VERSION)
	params.Add(SIGNATURE_METHOD_PARAM, SIGNATURE_METHOD)
	params.Add(TIMESTAMP_PARAM, strconv.Itoa64(c.clock.Seconds()))
	params.Add(NONCE_PARAM, strconv.Itoa64(c.nonceGenerator.Int63()))
	params.Add(CONSUMER_KEY_PARAM, consumerKey)
	for key, value := range additionalParams {
		params.Add(key, value)
	}
	return params
}
开发者ID:newblue,项目名称:oauth,代码行数:12,代码来源:oauth.go

示例7: UpdateContactOnExternalService

func (p *YahooContactService) UpdateContactOnExternalService(client oauth2_client.OAuth2Client, originalContact, contact interface{}) (interface{}, string, os.Error) {
	if contact == nil {
		return nil, "", nil
	}
	if originalContact == nil {
		return p.CreateContactOnExternalService(client, contact)
	}
	originalYContact := originalContact.(*yahoo.Contact)
	yContact := contact.(*yahoo.Contact)
	err := yahoo.UpdateContact(client, "", strconv.Itoa64(originalYContact.Id), yContact)
	return yContact, strconv.Itoa64(yContact.Id), err
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:12,代码来源:yahoo.go

示例8: module

func module(f string) (string, os.Error) {
	i, err := os.Stat(f)
	if err != nil {
		return "", err
	}

	m := "$" + f + "-" + strconv.Uitoa64(i.Dev) + "-" +
		strconv.Uitoa64(i.Ino) + "-" + strconv.Itoa64(i.Blocks) + "-" +
		strconv.Itoa64(i.Mtime_ns)

	return m, nil
}
开发者ID:machinaut,项目名称:oh,代码行数:12,代码来源:engine.go

示例9: Lrange

// Redis LRANGE command.
func (c *syncClient) Lrange(arg0 string, arg1 int64, arg2 int64) (result [][]byte, err Error) {
	arg0bytes := []byte(arg0)
	arg1bytes := []byte(strconv.Itoa64(arg1))
	arg2bytes := []byte(strconv.Itoa64(arg2))

	var resp Response
	resp, err = c.conn.ServiceRequest(&LRANGE, [][]byte{arg0bytes, arg1bytes, arg2bytes})
	if err == nil {
		result = resp.GetMultiBulkData()
	}
	return result, err

}
开发者ID:kpm,项目名称:Go-Redis,代码行数:14,代码来源:synchclient.go

示例10: Lrange

// Redis LRANGE command.
func (c *asyncClient) Lrange(arg0 string, arg1 int64, arg2 int64) (result FutureBytesArray, err Error) {
	arg0bytes := []byte(arg0)
	arg1bytes := []byte(strconv.Itoa64(arg1))
	arg2bytes := []byte(strconv.Itoa64(arg2))

	var resp *PendingResponse
	resp, err = c.conn.QueueRequest(&LRANGE, [][]byte{arg0bytes, arg1bytes, arg2bytes})
	if err == nil {
		result = resp.future.(FutureBytesArray)
	}
	return result, err

}
开发者ID:chronicaww,项目名称:Go-Redis,代码行数:14,代码来源:asynchclient.go

示例11: Encode

// Encode writes the Image m to w in PNG format. Any Image may be encoded, but
// images that are not image.NRGBA might be encoded lossily.
func Encode(w io.Writer, m image.Image) os.Error {
	// Obviously, negative widths and heights are invalid. Furthermore, the PNG
	// spec section 11.2.2 says that zero is invalid. Excessively large images are
	// also rejected.
	mw, mh := int64(m.Bounds().Dx()), int64(m.Bounds().Dy())
	if mw <= 0 || mh <= 0 || mw >= 1<<32 || mh >= 1<<32 {
		return FormatError("invalid image size: " + strconv.Itoa64(mw) + "x" + strconv.Itoa64(mw))
	}

	var e encoder
	e.w = w
	e.m = m

	var pal color.Palette
	// cbP8 encoding needs PalettedImage's ColorIndexAt method.
	if _, ok := m.(image.PalettedImage); ok {
		pal, _ = m.ColorModel().(color.Palette)
	}
	if pal != nil {
		e.cb = cbP8
	} else {
		switch m.ColorModel() {
		case color.GrayModel:
			e.cb = cbG8
		case color.Gray16Model:
			e.cb = cbG16
		case color.RGBAModel, color.NRGBAModel, color.AlphaModel:
			if opaque(m) {
				e.cb = cbTC8
			} else {
				e.cb = cbTCA8
			}
		default:
			if opaque(m) {
				e.cb = cbTC16
			} else {
				e.cb = cbTCA16
			}
		}
	}

	_, e.err = io.WriteString(w, pngHeader)
	e.writeIHDR()
	if pal != nil {
		e.writePLTE(pal)
		e.maybeWritetRNS(pal)
	}
	e.writeIDATs()
	e.writeIEND()
	return e.err
}
开发者ID:Sunmonds,项目名称:gcc,代码行数:53,代码来源:writer.go

示例12: formatReflectValue

func formatReflectValue(x reflect.Value) (string, os.Error) {
	/*
	   if !x.CanSet() {
	       return "", ErrorCantSet
	   }
	*/
	var (
		errc os.Error
		kind = x.Kind()
		//vintstr   string
	)
	switch kind {
	// Format pointers to standard types.
	case reflect.String:
		return x.Interface().(string), nil
	case reflect.Int:
		return strconv.Itoa(x.Interface().(int)), nil
	case reflect.Int8:
		return strconv.Itoa64(int64(x.Interface().(int8))), nil
	case reflect.Int16:
		return strconv.Itoa64(int64(x.Interface().(int16))), nil
	case reflect.Int32:
		return strconv.Itoa64(int64(x.Interface().(int32))), nil
	case reflect.Int64:
		return strconv.Itoa64(x.Interface().(int64)), nil
	case reflect.Uint:
		return strconv.Uitoa(x.Interface().(uint)), nil
	case reflect.Uint8:
		return strconv.Uitoa64(uint64(x.Interface().(uint8))), nil
	case reflect.Uint16:
		return strconv.Uitoa64(uint64(x.Interface().(uint16))), nil
	case reflect.Uint32:
		return strconv.Uitoa64(uint64(x.Interface().(uint32))), nil
	case reflect.Uint64:
		return strconv.Uitoa64(x.Interface().(uint64)), nil
	case reflect.Float32:
		return strconv.Ftoa32(x.Interface().(float32), FloatFmt, FloatPrec), nil
	case reflect.Float64:
		return strconv.Ftoa64(x.Interface().(float64), FloatFmt, FloatPrec), nil
	case reflect.Complex64:
		fallthrough
	case reflect.Complex128:
		errc = ErrorUnimplemented
	case reflect.Bool:
		return strconv.Btoa(x.Interface().(bool)), nil
	default:
		errc = ErrorFieldType
	}
	return "", errc
}
开发者ID:newblue,项目名称:csvutil,代码行数:50,代码来源:row.go

示例13: MakeRequest

func (c *AuthClient) MakeRequest(url string, additional_params map[string]string, token_secret string, protected bool) (r *http.Response, finalURL string, err os.Error) {

	log.Stderrf("make_request:url:%s:", url);
	for k,v := range additional_params {
		log.Stderrf("make_request:%s:%s:", k, v);
	}

	params := make(map[string]string);
	params["oauth_consumer_key"] = c.consumer_key;
	params["oauth_signature_method"] = "HMAC-SHA1";
	params["oauth_timestamp"] =  strconv.Itoa64(time.Seconds());
	params["oauth_nonce"] = strconv.Itoa64(rand.Int63());
	params["oauth_version"] = "1.0";

	//if token != "" {
	//	params["oauth_token"] = token;
	//}
	//else {
	//	params["oauth_callback"] = c.callback_url;
	//}

	// typically: oauth_token, oauth_callback, and/or oauth_verifier
	for k,v := range additional_params {
		params[k] = v;
	}

	for k,v := range params {
		log.Stderrf("param:%s:%s:", k, v);
	}

	m := BuildMessage(url, params);

	key := c.consumer_secret + "&" + token_secret;
	log.Stderrf("key:%s", key);

	digest_str := Digest(key, m);
	params["oauth_signature"] = digest_str;
	log.Stderrf("digest_str:%s", digest_str);

	sparams := urllib.Urlencode(params);
	log.Stderrf("sparams:%s", sparams);

	rurl := strings.Join([]string{url,sparams}, "?");

	log.Stderrf("make_request:rurl:%s", rurl);

	// TODO: no easy way to add header for Authorization:OAuth when protected...?
	return http.Get(rurl);
}
开发者ID:montsamu,项目名称:go-twitter-oauth,代码行数:49,代码来源:oauth.go

示例14: LoadPost

func LoadPost(ctx *web.Context, val string) {
	username := ctx.Params["username"]
	password := ctx.Params["password"]

	salt := strconv.Itoa64(time.Nanoseconds()) + username

	var h hash.Hash = sha256.New()
	h.Write([]byte(password + salt))

	s, _err := conn.Prepare("INSERT INTO users VALUES(NULL, ?, ?, ?)")
	utils.ReportErr(_err)

	s.Exec(username, string(h.Sum()), salt)
	s.Finalize()
	conn.Close()
	sidebar := utils.Loadmustache("admin.mustache", &map[string]string{})

	//TESTING, REMOVE LATER
	script := "<script type=\"text/javascript\" src=\"../inc/adminref.js\"></script>"
	content := "Welcome to the admin panel, use the control box on your right to control the site content"
	//ENDTESTING

	mapping := map[string]string{"css": "../inc/site.css",
		"title":   "Proggin: Admin panel",
		"sidebar": sidebar,
		"content": content,
		"script":  script}

	output := utils.Loadmustache("frame.mustache", &mapping)
	ctx.WriteString(output)
}
开发者ID:Chownie,项目名称:Proggin,代码行数:31,代码来源:newuser.go

示例15: SetSecureCookie

func SetSecureCookie(rw http.ResponseWriter, name, val, path string, timeout int64) {
	var buf bytes.Buffer

	e := base64.NewEncoder(base64.StdEncoding, &buf)
	e.Write([]byte(val))
	e.Close()

	ts := strconv.Itoa64(time.Seconds())
	data := strings.Join([]string{buf.String(), ts, getCookieSig(buf.Bytes(), ts)}, "|")

	var cookie string

	// Timeout of -1 is a special case that omits the entire 'expires' bit.
	// This is used for cookies which expire as soon as a user's session ends.
	if timeout != -1 {
		t := time.UTC()
		t = time.SecondsToUTC(t.Seconds() + timeout)
		ts = t.Format(time.RFC1123)
		ts = ts[0:len(ts)-3] + "GMT"
		cookie = fmt.Sprintf("%s=%s; expires=%s; path=%s", name, data, ts, path)
	} else {
		cookie = fmt.Sprintf("%s=%s; path=%s", name, data, path)
	}

	if context.Config().Secure {
		cookie += "; secure"
	}

	rw.SetHeader("Set-Cookie", cookie)
}
开发者ID:welterde,项目名称:mudkip,代码行数:30,代码来源:cookies.go


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