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


Golang strconv.Btoui64函数代码示例

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


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

示例1: Symbol

// Symbol looks up the program counters listed in the request,
// responding with a table mapping program counters to function names.
// The package initialization registers it as /debug/pprof/symbol.
func Symbol(c *http.Conn, r *http.Request) {
	c.SetHeader("content-type", "text/plain; charset=utf-8")

	// We don't know how many symbols we have, but we
	// do have symbol information.  Pprof only cares whether
	// this number is 0 (no symbols available) or > 0.
	fmt.Fprintf(c, "num_symbols: 1\n")

	var b *bufio.Reader
	if r.Method == "POST" {
		b = bufio.NewReader(r.Body)
	} else {
		b = bufio.NewReader(strings.NewReader(r.URL.RawQuery))
	}

	for {
		w, err := b.ReadSlice('+')
		if err == nil {
			w = w[0 : len(w)-1] // trim +
		}
		pc, _ := strconv.Btoui64(string(w), 0)
		if pc != 0 {
			f := runtime.FuncForPC(uintptr(pc))
			if f != nil {
				fmt.Fprintf(c, "%#x %s\n", pc, f.Name())
			}
		}

		// Wait until here to check for err; the last
		// symbol will have an err because it doesn't end in +.
		if err != nil {
			break
		}
	}
}
开发者ID:rapgamer,项目名称:golang-china,代码行数:38,代码来源:pprof.go

示例2: parseScript

func parseScript(line string, scripts map[string][]Script) {
	comment := strings.Index(line, "#")
	if comment >= 0 {
		line = line[0:comment]
	}
	line = strings.TrimSpace(line)
	if len(line) == 0 {
		return
	}
	field := strings.Split(line, ";")
	if len(field) != 2 {
		logger.Fatalf("%s: %d fields (expected 2)\n", line, len(field))
	}
	matches := scriptRe.FindStringSubmatch(line)
	if len(matches) != 4 {
		logger.Fatalf("%s: %d matches (expected 3)\n", line, len(matches))
	}
	lo, err := strconv.Btoui64(matches[1], 16)
	if err != nil {
		logger.Fatalf("%.5s...: %s", line, err)
	}
	hi := lo
	if len(matches[2]) > 2 { // ignore leading ..
		hi, err = strconv.Btoui64(matches[2][2:], 16)
		if err != nil {
			logger.Fatalf("%.5s...: %s", line, err)
		}
	}
	name := matches[3]
	scripts[name] = append(scripts[name], Script{uint32(lo), uint32(hi), name})
}
开发者ID:ssrl,项目名称:go,代码行数:31,代码来源:maketables.go

示例3: single_rune

// Consume a single rune; assumes this is being invoked as the last possible
// option and will panic if an invalid escape sequence is found. Will return the
// found rune (as an integer) and with cursor past the entire representation.
func (p *parser) single_rune() int {
	if rune := p.src.curr(); rune != '\\' {
		// This is just a regular character; return it immediately.
		p.src.nextCh()
		return rune
	}

	if p.src.peek() == 'x' {
		// Match hex character code.
		var hex string
		p.src.nextCh()
		if p.src.nextCh() == '{' {
			hex = p.src.literal("{", "}")
		} else {
			hex = fmt.Sprintf("%c%c", p.src.curr(), p.src.nextCh())
			p.src.nextCh() // Step over the end of the hex code.
		}

		// Parse and return the corresponding rune.
		rune, err := strconv.Btoui64(hex, 16)
		if err != nil {
			panic(fmt.Sprintf("couldn't parse hex: %s", hex))
		}
		return int(rune)
	} else if rune := ESCAPES[p.src.peek()]; rune != 0 {
		// Literally match '\n', '\r', etc.
		p.src.nextCh()
		p.src.nextCh()
		return rune
	} else if unicode.Is(_punct, p.src.peek()) {
		// Allow punctuation to be blindly escaped.
		rune := p.src.nextCh()
		p.src.nextCh()
		return rune
	} else if unicode.IsDigit(p.src.peek()) {
		// Match octal character code (begins with digit, up to three digits).
		oct := ""
		p.src.nextCh()
		for i := 0; i < 3; i++ {
			oct += fmt.Sprintf("%c", p.src.curr())
			if !unicode.IsDigit(p.src.nextCh()) {
				break
			}
		}

		// Parse and return the corresponding rune.
		rune, err := strconv.Btoui64(oct, 8)
		if err != nil {
			panic(fmt.Sprintf("couldn't parse oct: %s", oct))
		}
		return int(rune)
	}

	// This is an escape sequence which does not identify a single rune.
	panic(fmt.Sprintf("not a valid escape sequence: \\%c", p.src.peek()))
}
开发者ID:nuin,项目名称:ampify,代码行数:59,代码来源:regexp.go

示例4: beginChunk

func (cr *chunkedReader) beginChunk() {
	// chunk-size CRLF
	var line string
	line, cr.err = readLine(cr.r)
	if cr.err != nil {
		return
	}
	cr.n, cr.err = strconv.Btoui64(line, 16)
	if cr.err != nil {
		return
	}
	if cr.n == 0 {
		// trailer CRLF
		for {
			line, cr.err = readLine(cr.r)
			if cr.err != nil {
				return
			}
			if line == "" {
				break
			}
		}
		cr.err = os.EOF
	}
}
开发者ID:vablaya,项目名称:gopp-cs345,代码行数:25,代码来源:request.go

示例5: serveSymbol

func serveSymbol(req *web.Request) {
	var p []byte
	if req.Method == "POST" {
		var err os.Error
		p, err = req.BodyBytes(-1)
		if err != nil {
			req.Error(web.StatusInternalServerError, err)
			return
		}
	} else {
		p = []byte(req.URL.RawQuery)
	}

	w := respondText(req)
	io.WriteString(w, "num_symbols: 1\n")
	for len(p) > 0 {
		var a []byte
		if i := bytes.IndexByte(p, '+'); i >= 0 {
			a = p[:i]
			p = p[i+1:]
		} else {
			a = p
			p = nil
		}
		if pc, _ := strconv.Btoui64(string(a), 0); pc != 0 {
			if f := runtime.FuncForPC(uintptr(pc)); f != nil {
				fmt.Fprintf(w, "%#x %s\n", pc, f.Name())
			}
		}
	}
}
开发者ID:rene-dev,项目名称:twister,代码行数:31,代码来源:pprof.go

示例6: scanUint

// scanUint returns the value of the unsigned integer represented
// by the next token, checking for overflow.  Any error is stored in s.err.
func (s *ss) scanUint(verb int, bitSize int) uint64 {
	if verb == 'c' {
		return uint64(s.scanRune(bitSize))
	}
	s.skipSpace(false)
	base, digits := s.getBase(verb)
	haveDigits := false
	if verb == 'U' {
		if !s.consume("U", false) || !s.consume("+", false) {
			s.errorString("bad unicode format ")
		}
	} else if verb == 'v' {
		base, digits, haveDigits = s.scanBasePrefix()
	}
	tok := s.scanNumber(digits, haveDigits)
	i, err := strconv.Btoui64(tok, base)
	if err != nil {
		s.error(err)
	}
	n := uint(bitSize)
	x := (i << (64 - n)) >> (64 - n)
	if x != i {
		s.errorString("unsigned integer overflow on token " + tok)
	}
	return i
}
开发者ID:go-nosql,项目名称:golang,代码行数:28,代码来源:scan.go

示例7: TestRunServer

func TestRunServer(t *testing.T) {
	if !*serve {
		return
	}

	suites := strings.Split(*testCipherSuites, ",")
	testConfig.CipherSuites = make([]uint16, len(suites))
	for i := range suites {
		suite, err := strconv.Btoui64(suites[i], 0)
		if err != nil {
			panic(err)
		}
		testConfig.CipherSuites[i] = uint16(suite)
	}

	l, err := Listen("tcp", ":10443", testConfig)
	if err != nil {
		t.Fatal(err)
	}

	for {
		c, err := l.Accept()
		if err != nil {
			break
		}
		_, err = c.Write([]byte("hello, world\n"))
		if err != nil {
			t.Errorf("error from TLS: %s", err)
			break
		}
		c.Close()
	}
}
开发者ID:Quantumboost,项目名称:gcc,代码行数:33,代码来源:handshake_server_test.go

示例8: Mknod

func Mknod(call []string) error {
	e := flagSet.Parse(call[1:])
	if e != nil {
		return e
	}

	if flagSet.NArg() != 1 || *helpFlag {
		println("`mknod` [options] <file>")
		flagSet.PrintDefaults()
		return nil
	}

	mode, ok := typemap[strings.ToLower(*typeFlag)]
	if !ok {
		return errors.New("Invalid node type \"" + *typeFlag + "\"")
	}

	if mode == syscall.S_IFBLK && (*majorFlag == -1 || *minorFlag == -1) {
		return errors.New("When creating a block device, both minor and major number have to be given")
	}

	fmode, e := strconv.Btoui64(*modeFlag, 8)
	if e != nil {
		return e
	}
	mode |= uint32(fmode)

	e = syscall.Mknod(flagSet.Arg(0), mode, *majorFlag<<8|*minorFlag)
	return e
}
开发者ID:akrennmair,项目名称:gobox,代码行数:30,代码来源:mknod.go

示例9: hexPairToByte

func hexPairToByte(rune1 int, rune2 int) byte {
	// TODO: this one is slowpoke probably
	s := string([]byte{byte(rune1), byte(rune2)})
	ui, err := strconv.Btoui64(s, 16)
	if err != nil {
		panic(err)
	}
	return byte(ui)
}
开发者ID:nsf,项目名称:shebang,代码行数:9,代码来源:lexer.go

示例10: loadCasefold

func loadCasefold() {
	if *casefoldingURL == "" {
		flag.Set("casefolding", *url+"CaseFolding.txt")
	}
	resp, err := http.Get(*casefoldingURL)
	if err != nil {
		logger.Fatal(err)
	}
	if resp.StatusCode != 200 {
		logger.Fatal("bad GET status for CaseFolding.txt", resp.Status)
	}
	input := bufio.NewReader(resp.Body)
	for {
		line, err := input.ReadString('\n')
		if err != nil {
			if err == os.EOF {
				break
			}
			logger.Fatal(err)
		}
		if line[0] == '#' {
			continue
		}
		field := strings.Split(line, "; ")
		if len(field) != 4 {
			logger.Fatalf("CaseFolding.txt %.5s...: %d fields (expected %d)\n", line, len(field), 4)
		}
		kind := field[1]
		if kind != "C" && kind != "S" {
			// Only care about 'common' and 'simple' foldings.
			continue
		}
		p1, err := strconv.Btoui64(field[0], 16)
		if err != nil {
			logger.Fatalf("CaseFolding.txt %.5s...: %s", line, err)
		}
		p2, err := strconv.Btoui64(field[2], 16)
		if err != nil {
			logger.Fatalf("CaseFolding.txt %.5s...: %s", line, err)
		}
		chars[p1].foldCase = int(p2)
	}
	resp.Body.Close()
}
开发者ID:ssrl,项目名称:go,代码行数:44,代码来源:maketables.go

示例11: getu4

// getu4 decodes \uXXXX from the beginning of s, returning the hex value,
// or it returns -1.
func getu4(s []byte) int {
	if len(s) < 6 || s[0] != '\\' || s[1] != 'u' {
		return -1
	}
	rune, err := strconv.Btoui64(string(s[2:6]), 16)
	if err != nil {
		return -1
	}
	return int(rune)
}
开发者ID:Sunmonds,项目名称:gcc,代码行数:12,代码来源:decode.go

示例12: getu4

// getu4 decodes \uXXXX from the beginning of s, returning the hex value,
// or it returns -1.
func getu4(s []byte) rune {
	if len(s) < 6 || s[0] != '\\' || s[1] != 'u' {
		return -1
	}
	r, err := strconv.Btoui64(string(s[2:6]), 16)
	if err != nil {
		return -1
	}
	return rune(r)
}
开发者ID:aubonbeurre,项目名称:gcc,代码行数:12,代码来源:decode.go

示例13: letterValue

func (char *Char) letterValue(s string, cas string) int {
	if s == "" {
		return 0
	}
	v, err := strconv.Btoui64(s, 16)
	if err != nil {
		char.dump(cas)
		logger.Fatalf("%U: bad letter(%s): %s", char.codePoint, s, err)
	}
	return int(v)
}
开发者ID:ssrl,项目名称:go,代码行数:11,代码来源:maketables.go

示例14: letterValue

func (char *Char) letterValue(s string, cas string) int {
	if s == "" {
		return 0
	}
	v, err := strconv.Btoui64(s, 16);
	if err != nil {
		char.dump(cas);
		die.Logf("U+%04x: bad letter(%s): %s", char.codePoint, s, err);
	}
	return int(v);
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:11,代码来源:maketables.go

示例15: parseScript

func parseScript(line string, scripts map[string][]Script) {
	comment := strings.Index(line, "#");
	if comment >= 0 {
		line = line[0:comment]
	}
	line = strings.TrimSpace(line);
	if len(line) == 0 {
		return
	}
	field := strings.Split(line, ";", -1);
	if len(field) != 2 {
		die.Logf("%s: %d fields (expected 2)\n", line, len(field))
	}
	matches := scriptRe.MatchStrings(line);
	if len(matches) != 4 {
		die.Logf("%s: %d matches (expected 3)\n", line, len(matches))
	}
	lo, err := strconv.Btoui64(matches[1], 16);
	if err != nil {
		die.Log("%.5s...:", err)
	}
	hi := lo;
	if len(matches[2]) > 2 {	// ignore leading ..
		hi, err = strconv.Btoui64(matches[2][2:len(matches[2])], 16);
		if err != nil {
			die.Log("%.5s...:", err)
		}
	}
	name := matches[3];
	s, ok := scripts[name];
	if !ok || len(s) == cap(s) {
		ns := make([]Script, len(s), len(s)+100);
		for i, sc := range s {
			ns[i] = sc
		}
		s = ns;
	}
	s = s[0 : len(s)+1];
	s[len(s)-1] = Script{uint32(lo), uint32(hi), name};
	scripts[name] = s;
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:41,代码来源:maketables.go


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