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


Golang strconv.Atob函数代码示例

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


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

示例1: StartTiling

func StartTiling(w http.ResponseWriter, req *http.Request) {
	if reset != nil {
		select {
		case <-reset:
			reset <- 1
		case reset <- 1:
		}
	}

	tilingType := req.FormValue("type")
	tileSymmetry := req.FormValue("symmetry")

	if tilingType == "skeleton" {
		skeleton := req.FormValue("skeleton")
		showIntermediate, ok := strconv.Atob(req.FormValue("intermediate"))
		if ok != nil || skeleton == "" {
			w.WriteHeader(http.StatusNotFound)
		}
		ZellijTilings, reset = zellij.TileSkeleton(skeleton, tileSymmetry, showIntermediate)
		w.WriteHeader(http.StatusOK)
		return
	} else if tilingType == "plane" {
		maxtiles, okm := strconv.Atoi(req.FormValue("maxtiles"))
		showIntermediate, oks := strconv.Atob(req.FormValue("intermediate"))
		if okm != nil || oks != nil || maxtiles == 0 {
			w.WriteHeader(http.StatusNotFound)
		}
		ZellijTilings, reset = zellij.TilePlane(maxtiles, tileSymmetry, showIntermediate)
		w.WriteHeader(http.StatusOK)
		return
	}

	w.WriteHeader(http.StatusNotFound)
}
开发者ID:ebering,项目名称:zellij,代码行数:34,代码来源:interactive.go

示例2: load_options

func load_options() {
	reader, file := take_reader_from_file(os.Getenv("HOME") + "/.tabbyoptions")
	defer file.Close()
	var str string
	for next_string_from_reader(reader, &str) {
		args := strings.Split(compact_space(str), "\t", -1)
		switch args[0] {
		case "space_not_tab":
			opt.space_not_tab, _ = strconv.Atob(args[1])
		case "show_search":
			opt.show_search, _ = strconv.Atob(args[1])
		case "show_error":
			opt.show_error, _ = strconv.Atob(args[1])
		case "ihp_position":
			opt.ihp_position = atoi(args[1])
		case "ohp_position":
			opt.ohp_position = atoi(args[1])
		case "vvp_position":
			opt.vvp_position = atoi(args[1])
		case "alloc_window":
			opt.window_width, opt.window_height, opt.window_x, opt.window_y = atoi(args[1]),
				atoi(args[2]), atoi(args[3]), atoi(args[4])
		case "font":
			opt.font = args[1]
		case "tabsize":
			opt.tabsize = atoi(args[1])
		}
	}
}
开发者ID:mattn,项目名称:tabby,代码行数:29,代码来源:options.go

示例3: Ab

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

示例4: B

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

示例5: setBoolFlag

// setBoolFlag sets the addressed boolean to the value.
func setBoolFlag(flag *bool, value string) {
	x, err := strconv.Atob(value)
	if err != nil {
		fmt.Fprintf(os.Stderr, "gotest: illegal bool flag value %s\n", value)
		usage()
	}
	*flag = x
}
开发者ID:WXB506,项目名称:golang,代码行数:9,代码来源:flag.go

示例6: client_callback

func client_callback(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	itsStatus, _ := strconv.Atob(r.FormValue("Status"))
	msg := MSG{itsStatus, r.FormValue("Nickname"), r.FormValue("Message")}
	for _, value := range map_clients {
		channel.SendJSON(c, value, msg)
	}
}
开发者ID:tbocs,项目名称:webapp-experiments,代码行数:8,代码来源:tbocsincloud.go

示例7: B

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

示例8: B

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

示例9: Bool

func (p *parser) Bool(v *bool, s string, r bool) {
	if p.err != nil || (!r && p.r.FormValue(s) == "") {
		return
	}
	*v, p.err = strconv.Atob(p.r.FormValue(s))
	if p.err != nil {
		p.err = fmt.Errorf("Parsing %s [bool]: %q", s, p.err)
	}
}
开发者ID:zeebo,项目名称:gorain,代码行数:9,代码来源:announce_parser.go

示例10: 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

示例11: newVal

func newVal(lit string) Value {
	x, err := strconv.Atoi(lit)
	if err == nil {
		return Int(x)
	}
	b, err := strconv.Atob(lit)
	if err == nil {
		return Bool(b)
	}
	return Error(fmt.Sprintf("illegal literal '%s'", lit))
}
开发者ID:go-nosql,项目名称:golang,代码行数:11,代码来源:eval1.go

示例12: SetValue

// Set Value From HTMLForm Values
func (t *Tasks) SetValue(Id string, r *http.Request) os.Error {

	var err os.Error

	t.UserId = Id
	t.KeyID, err = strconv.Atoi64(r.FormValue(FORM_KEY))
	if err != nil {
		t.KeyID = 0
	}
	t.Status, err = strconv.Atoi(r.FormValue(FORM_STATUS))
	if err != nil {
		log.Println(err)
		return err
	}

	log.Println("Status")

	t.Context = html.EscapeString(r.FormValue(FORM_CONTEXT))
	t.IsUseLimit, err = strconv.Atob(r.FormValue(FORM_LIMIT))
	if err != nil {
		log.Println(err)
		return err
	}

	log.Println("IsUseLimit")

	t.IsComplete = (t.Status == 2)
	t.IsCanceld = (t.Status == 9)

	log.Println("Set Bool Value")

	if t.IsUseLimit {

		log.Println(r.FormValue(FORM_DATE))
		log.Println(time.RFC3339)
		var limit *time.Time
		limit, err = time.Parse("2006-01-02 15:04:05", r.FormValue(FORM_DATE))
		if err == nil {
			t.PlanDate = datastore.SecondsToTime(limit.Seconds())
		} else {
			log.Println(err)
			return err
		}
	}

	log.Println("PostDate")
	t.PostDate = datastore.SecondsToTime(time.Seconds())
	if t.IsComplete {
		t.CompleteDate = datastore.SecondsToTime(time.Seconds())
	}

	return nil

}
开发者ID:dotroidxx,项目名称:d3tasks,代码行数:55,代码来源:models.go

示例13: writeTo

func writeTo(data []byte, val reflect.Value) os.Error {
	s := string(data)
	switch v := val.(type) {
	// if we're writing to an interace value, just set the byte data
	// TODO: should we support writing to a pointer?
	case *reflect.InterfaceValue:
		v.Set(reflect.NewValue(data))
	case *reflect.BoolValue:
		b, err := strconv.Atob(s)
		if err != nil {
			return err
		}
		v.Set(b)
	case *reflect.IntValue:
		i, err := strconv.Atoi64(s)
		if err != nil {
			return err
		}
		v.Set(i)
	case *reflect.UintValue:
		ui, err := strconv.Atoui64(s)
		if err != nil {
			return err
		}
		v.Set(ui)
	case *reflect.FloatValue:
		f, err := strconv.Atof64(s)
		if err != nil {
			return err
		}
		v.Set(f)

	case *reflect.StringValue:
		v.Set(s)
	case *reflect.SliceValue:
		typ := v.Type().(*reflect.SliceType)
		if _, ok := typ.Elem().(*reflect.UintType); ok {
			v.Set(reflect.NewValue(data).(*reflect.SliceValue))
		}
	}
	return nil
}
开发者ID:wladh,项目名称:redis.go,代码行数:42,代码来源:redis.go

示例14: writeTo

func writeTo(data []byte, val reflect.Value) os.Error {
	s := string(data)
	switch v := val; v.Kind() {
	// if we're writing to an interace value, just set the byte data
	// TODO: should we support writing to a pointer?
	case reflect.Interface:
		v.Set(reflect.ValueOf(data))
	case reflect.Bool:
		b, err := strconv.Atob(s)
		if err != nil {
			return err
		}
		v.SetBool(b)
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		i, err := strconv.Atoi64(s)
		if err != nil {
			return err
		}
		v.SetInt(i)
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		ui, err := strconv.Atoui64(s)
		if err != nil {
			return err
		}
		v.SetUint(ui)
	case reflect.Float32, reflect.Float64:
		f, err := strconv.Atof64(s)
		if err != nil {
			return err
		}
		v.SetFloat(f)

	case reflect.String:
		v.SetString(s)
	case reflect.Slice:
		typ := v.Type()
		if typ.Elem().Kind() == reflect.Uint || typ.Elem().Kind() == reflect.Uint8 || typ.Elem().Kind() == reflect.Uint16 || typ.Elem().Kind() == reflect.Uint32 || typ.Elem().Kind() == reflect.Uint64 || typ.Elem().Kind() == reflect.Uintptr {
			v.Set(reflect.ValueOf(data))
		}
	}
	return nil
}
开发者ID:alangenfeld,项目名称:flock,代码行数:42,代码来源:redis.go

示例15: GetRequestToken

func (o *OAuthClient) GetRequestToken(callback string) *RequestToken {
	nonce := getNonce(40)
	params := map[string]string{
		"oauth_nonce":            nonce,
		"oauth_callback":         URLEscape(callback),
		"oauth_signature_method": "HMAC-SHA1",
		"oauth_timestamp":        strconv.Itoa64(time.Seconds()),
		"oauth_consumer_key":     o.ConsumerKey,
		"oauth_version":          "1.0",
	}

	base := signatureBase("POST", requestTokenUrl.Raw, params)
	signature := signRequest(base, o.ConsumerSecret, "")
	params["oauth_signature"] = URLEscape(signature)

	authBuf := bytes.NewBufferString("OAuth ")
	i := 0
	for k, v := range params {
		authBuf.WriteString(fmt.Sprintf("%s=%q", k, v))
		if i < len(params)-1 {
			authBuf.WriteString(", ")
		}
		i++
	}
	request := httplib.Post(requestTokenUrl.Raw)
	request.Header("Authorization", authBuf.String())
	request.Body("")
	resp, err := request.AsString()
	tokens, err := http.ParseQuery(resp)
	if err != nil {
		println(err.String())
	}

	confirmed, _ := strconv.Atob(tokens["oauth_callback_confirmed"][0])
	rt := RequestToken{
		OAuthTokenSecret:       tokens["oauth_token_secret"][0],
		OAuthToken:             tokens["oauth_token"][0],
		OAuthCallbackConfirmed: confirmed,
	}
	return &rt
}
开发者ID:gmarik,项目名称:twitterstream,代码行数:41,代码来源:oauth.go


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