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


Golang strconv.FormatBool函数代码示例

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


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

示例1: Valid

// Valid returns true if every validation passes.
func (cv *ChartValidation) Valid() bool {
	var valid bool = true

	fmt.Printf("\nVerifying %s chart is a valid chart...\n", cv.ChartName())
	cv.walk(func(v *Validation) bool {
		v.path = cv.Path
		vv := v.valid()
		if !vv {
			switch v.level {
			case 2:
				cv.ErrorCount = cv.ErrorCount + 1
				msg := v.Message + " : " + strconv.FormatBool(vv)
				log.Err(msg)
			case 1:
				cv.WarningCount = cv.WarningCount + 1
				msg := v.Message + " : " + strconv.FormatBool(vv)
				log.Warn(msg)
			}
		} else {
			msg := v.Message + " : " + strconv.FormatBool(vv)
			log.Info(msg)
		}

		valid = valid && vv
		return valid
	})

	return valid
}
开发者ID:michelleN,项目名称:helm,代码行数:30,代码来源:validation.go

示例2: String

func (v Volume) String() string {
	s := []string{
		v.Name.String(),
		",kind=",
		v.Kind,
	}
	if v.Source != "" {
		s = append(s, ",source=")
		s = append(s, v.Source)
	}
	if v.ReadOnly != nil {
		s = append(s, ",readOnly=")
		s = append(s, strconv.FormatBool(*v.ReadOnly))
	}
	if v.Recursive != nil {
		s = append(s, ",recursive=")
		s = append(s, strconv.FormatBool(*v.Recursive))
	}
	switch v.Kind {
	case "empty":
		if *v.Mode != emptyVolumeDefaultMode {
			s = append(s, ",mode=")
			s = append(s, *v.Mode)
		}
		if *v.UID != emptyVolumeDefaultUID {
			s = append(s, ",uid=")
			s = append(s, strconv.Itoa(*v.UID))
		}
		if *v.GID != emptyVolumeDefaultGID {
			s = append(s, ",gid=")
			s = append(s, strconv.Itoa(*v.GID))
		}
	}
	return strings.Join(s, "")
}
开发者ID:blablacar,项目名称:dgr,代码行数:35,代码来源:volume.go

示例3: clientStats

func clientStats(c ClientStats, acc telegraf.Accumulator, host, version, topic, channel string) {
	tags := map[string]string{
		"server_host":       host,
		"server_version":    version,
		"topic":             topic,
		"channel":           channel,
		"client_name":       c.Name,
		"client_id":         c.ID,
		"client_hostname":   c.Hostname,
		"client_version":    c.Version,
		"client_address":    c.RemoteAddress,
		"client_user_agent": c.UserAgent,
		"client_tls":        strconv.FormatBool(c.TLS),
		"client_snappy":     strconv.FormatBool(c.Snappy),
		"client_deflate":    strconv.FormatBool(c.Deflate),
	}

	fields := map[string]interface{}{
		"ready_count":    c.ReadyCount,
		"inflight_count": c.InFlightCount,
		"message_count":  c.MessageCount,
		"finish_count":   c.FinishCount,
		"requeue_count":  c.RequeueCount,
	}
	acc.AddFields("nsq_client", fields, tags)
}
开发者ID:NathanielMichael,项目名称:telegraf,代码行数:26,代码来源:nsq.go

示例4: ListSprints

/*
 List sprints

 rapidViewId 	int		Id of board
 history 		bool 	List completed sprints
 future			bool	List sprints in the future

*/
func (j *Jira) ListSprints(rapidViewId int, history bool, future bool) (*Sprints, error) {

	url := j.BaseUrl + j.GreenHopper + sprintQuery_url + "/" + strconv.Itoa(rapidViewId) + "?"

	url += "includeHistoricSprints=" + strconv.FormatBool(history)
	url += "&includeFutureSprints=" + strconv.FormatBool(future)

	if j.Debug {
		fmt.Println(url)
	}

	contents := j.buildAndExecRequest("GET", url, nil)

	sprints := new(Sprints)
	err := json.Unmarshal(contents, &sprints)
	if err != nil {
		fmt.Println("%s", err)
	}

	if j.Debug {
		fmt.Println(sprints)
	}

	return sprints, err
}
开发者ID:odk-,项目名称:go-jira-client,代码行数:33,代码来源:sprints.go

示例5: setupWebSocket

// Initialize websocket from incus
func setupWebSocket(cfg config.WebConfig, ds *data.DataStore) {
	mymap := make(map[string]string)

	mymap["client_broadcasts"] = strconv.FormatBool(cfg.ClientBroadcasts)
	mymap["connection_timeout"] = strconv.Itoa(cfg.ConnTimeout)
	mymap["redis_enabled"] = strconv.FormatBool(cfg.RedisEnabled)
	mymap["debug"] = "true"

	conf := incus.InitConfig(mymap)
	store := incus.InitStore(&conf)
	Websocket = incus.CreateServer(&conf, store)

	log.LogInfo("Incus Websocket Init")

	go func() {
		for {
			select {
			case msg := <-ds.NotifyMailChan:
				go Websocket.AppListener(msg)
			}
		}
	}()

	go Websocket.RedisListener()
	go Websocket.SendHeartbeats()
}
开发者ID:jmcarbo,项目名称:smtpd-1,代码行数:27,代码来源:server.go

示例6: render

func (c *autoScaleInfoCmd) render(context *cmd.Context, config *autoScaleConfig, rules []autoScaleRule) error {
	fmt.Fprintf(context.Stdout, "Metadata filter: %s\n\n", config.GroupByMetadata)
	var table cmd.Table
	tableHeader := []string{
		"Filter value",
		"Max container count",
		"Max memory ratio",
		"Scale down ratio",
		"Rebalance on scale",
		"Enabled",
	}
	table.Headers = tableHeader
	for _, rule := range rules {
		table.AddRow([]string{
			rule.MetadataFilter,
			strconv.Itoa(rule.MaxContainerCount),
			strconv.FormatFloat(float64(rule.MaxMemoryRatio), 'f', 4, 32),
			strconv.FormatFloat(float64(rule.ScaleDownRatio), 'f', 4, 32),
			strconv.FormatBool(!rule.PreventRebalance),
			strconv.FormatBool(rule.Enabled),
		})
	}
	fmt.Fprintf(context.Stdout, "Rules:\n%s", table.String())
	return nil
}
开发者ID:Endika,项目名称:tsuru,代码行数:25,代码来源:cmd.go

示例7: New

func (c Client) New(params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) {
	body := &stripe.RequestValues{}
	body.Add("customer", params.Customer)
	body.Add("amount", strconv.FormatInt(params.Amount, 10))
	body.Add("currency", string(params.Currency))

	if len(params.Invoice) > 0 {
		body.Add("invoice", params.Invoice)
	}

	if len(params.Desc) > 0 {
		body.Add("description", params.Desc)
	}

	if len(params.Sub) > 0 {
		body.Add("subscription", params.Sub)
	}

	if params.Discountable {
		body.Add("discountable", strconv.FormatBool(true))
	} else if params.NoDiscountable {
		body.Add("discountable", strconv.FormatBool(false))
	}

	params.AppendTo(body)

	invoiceItem := &stripe.InvoiceItem{}
	err := c.B.Call("POST", "/invoiceitems", c.Key, body, &params.Params, invoiceItem)

	return invoiceItem, err
}
开发者ID:captain401,项目名称:stripe-go,代码行数:31,代码来源:client.go

示例8: makeRequestData

func makeRequestData(k string, c map[string]interface{}, f url.Values) {
	if k != "" {
		k = k + "."
	}

	for _k, _v := range c {
		key := k + _k
		switch _s := _v.(type) {
		case []interface{}:
			for i, v := range _s {
				switch s := v.(type) {
				case string:
					f.Add(key, s)
				case json.Number:
					f.Add(key, s.String())
				case bool:
					f.Add(key, strconv.FormatBool(s))
				case map[string]interface{}:
					if key != "" {
						key = fmt.Sprintln("%s.%d", key, i)
					}
					makeRequestData(key, s, f)
				}
			}
		case string:
			f.Add(key, _s)
		case json.Number:
			f.Add(key, _s.String())
		case bool:
			f.Add(key, strconv.FormatBool(_s))
		case map[string]interface{}:
			makeRequestData(key, _s, f)
		}
	}
}
开发者ID:zaolab,项目名称:sunnified,代码行数:35,代码来源:context.go

示例9: build

// Build builds the camlistore command at the given path from the source tree root.
func build(path string) error {
	if v, _ := strconv.ParseBool(os.Getenv("CAMLI_FAST_DEV")); v {
		// Demo mode. See dev/demo.sh.
		return nil
	}
	_, cmdName := filepath.Split(path)
	target := filepath.Join("camlistore.org", path)
	binPath := filepath.Join("bin", cmdName)
	var modtime int64
	fi, err := os.Stat(binPath)
	if err != nil {
		if !os.IsNotExist(err) {
			return fmt.Errorf("Could not stat %v: %v", binPath, err)
		}
	} else {
		modtime = fi.ModTime().Unix()
	}
	args := []string{
		"run", "make.go",
		"--quiet",
		"--race=" + strconv.FormatBool(*race),
		"--embed_static=false",
		"--sqlite=" + strconv.FormatBool(withSqlite),
		fmt.Sprintf("--if_mods_since=%d", modtime),
		"--targets=" + target,
	}
	cmd := exec.Command("go", args...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		return fmt.Errorf("Error building %v: %v", target, err)
	}
	return nil
}
开发者ID:jayvansantos,项目名称:camlistore,代码行数:35,代码来源:devcam.go

示例10: ContainerLogs

func (client *DockerClient) ContainerLogs(id string, options *LogOptions) (io.ReadCloser, error) {
	v := url.Values{}
	v.Add("follow", strconv.FormatBool(options.Follow))
	v.Add("stdout", strconv.FormatBool(options.Stdout))
	v.Add("stderr", strconv.FormatBool(options.Stderr))
	v.Add("timestamps", strconv.FormatBool(options.Timestamps))
	if options.Tail > 0 {
		v.Add("tail", strconv.FormatInt(options.Tail, 10))
	}
	if options.Since > 0 {
		v.Add("since", strconv.Itoa(options.Since))
	}

	uri := fmt.Sprintf("/%s/containers/%s/logs?%s", APIVersion, id, v.Encode())
	req, err := http.NewRequest("GET", client.URL.String()+uri, nil)
	if err != nil {
		return nil, err
	}
	req.Header.Add("Content-Type", "application/json")
	resp, err := client.HTTPClient.Do(req)
	if err != nil {
		return nil, err
	}
	return resp.Body, nil
}
开发者ID:SlavD,项目名称:dockerclient,代码行数:25,代码来源:dockerclient.go

示例11: Values

// Serialize the context back to URL values.
func (c *Env) Values() url.Values {
	values := url.Values{}
	if c.appID != c.defaultAppID {
		values.Set("appid", strconv.FormatUint(c.appID, 10))
	}
	if c.Env != defaultContext.Env {
		values.Set("server", c.Env)
	}
	if c.locale != defaultContext.locale {
		values.Set("locale", c.locale)
	}
	if c.Module != defaultContext.Module {
		values.Set("module", c.Module)
	}
	if c.Init != defaultContext.Init {
		values.Set("init", strconv.FormatBool(c.Init))
	}
	if c.Status != defaultContext.Status {
		values.Set("status", strconv.FormatBool(c.Status))
	}
	if c.FrictionlessRequests != defaultContext.FrictionlessRequests {
		values.Set("frictionlessRequests", strconv.FormatBool(c.FrictionlessRequests))
	}
	return values
}
开发者ID:chrisp-fb,项目名称:rell,代码行数:26,代码来源:context.go

示例12: prepareRktRunArguments

func (aci *Aci) prepareRktRunArguments(command common.BuilderCommand, builderHash string, stage1Hash string) []string {
	var args []string

	if logs.IsDebugEnabled() {
		args = append(args, "--debug")
	}
	args = append(args, "--set-env="+common.EnvDgrVersion+"="+BuildVersion)
	args = append(args, "--set-env="+common.EnvLogLevel+"="+logs.GetLevel().String())
	args = append(args, "--set-env="+common.EnvAciPath+"="+aci.path)
	args = append(args, "--set-env="+common.EnvAciTarget+"="+aci.target)
	args = append(args, "--set-env="+common.EnvBuilderCommand+"="+string(command))
	args = append(args, "--set-env="+common.EnvCatchOnError+"="+strconv.FormatBool(aci.args.CatchOnError))
	args = append(args, "--set-env="+common.EnvCatchOnStep+"="+strconv.FormatBool(aci.args.CatchOnStep))
	args = append(args, "--net=host")
	args = append(args, "--insecure-options=image")
	args = append(args, "--uuid-file-save="+aci.target+pathBuilderUuid)
	args = append(args, "--interactive")
	if stage1Hash != "" {
		args = append(args, "--stage1-hash="+stage1Hash)
	} else {
		args = append(args, "--stage1-name="+aci.manifest.Builder.Image.String())
	}

	for _, v := range aci.args.SetEnv.Strings() {
		args = append(args, "--set-env="+v)
	}
	args = append(args, builderHash)
	return args
}
开发者ID:blablacar,项目名称:dgr,代码行数:29,代码来源:aci-build.go

示例13: concatenateStringAndInt

func concatenateStringAndInt(a interface{}, b interface{}) (string, bool) {
	var aString string

	switch v := a.(type) {
	case string:
		aString = v
	case int64:
		aString = strconv.FormatInt(v, 10)
	case bool:
		aString = strconv.FormatBool(v)
	default:
		return "", false
	}

	switch v := b.(type) {
	case string:
		return aString + v, true
	case int64:
		return aString + strconv.FormatInt(v, 10), true
	case bool:
		return aString + strconv.FormatBool(v), true
	default:
		return "", false
	}
}
开发者ID:gstackio,项目名称:spiff,代码行数:25,代码来源:concatenation.go

示例14: show

func (cmd *Activity) show(activityId string) {
	activity, err := activities.Activity(cmd.network, activityId)
	if nil != err {
		error_handler.ErrorExit(err)
	}

	table := terminal.NewTable([]string{"Id:", activity.Id})
	table.Add("DisplayName:", activity.DisplayName)
	table.Add("Description:", activity.Description)
	table.Add("EntityId:", activity.EntityId)
	table.Add("EntityDisplayName:", activity.EntityDisplayName)
	table.Add("Submitted:", time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate))
	table.Add("Started:", time.Unix(activity.StartTimeUtc/1000, 0).Format(time.UnixDate))
	table.Add("Ended:", time.Unix(activity.EndTimeUtc/1000, 0).Format(time.UnixDate))
	table.Add("CurrentStatus:", activity.CurrentStatus)
	table.Add("IsError:", strconv.FormatBool(activity.IsError))
	table.Add("IsCancelled:", strconv.FormatBool(activity.IsCancelled))
	table.Add("SubmittedByTask:", activity.SubmittedByTask.Metadata.Id)
	if activity.Streams["stdin"].Metadata.Size > 0 ||
		activity.Streams["stdout"].Metadata.Size > 0 ||
		activity.Streams["stderr"].Metadata.Size > 0 ||
		activity.Streams["env"].Metadata.Size > 0 {
		table.Add("Streams:", fmt.Sprintf("stdin: %d, stdout: %d, stderr: %d, env %d",
			activity.Streams["stdin"].Metadata.Size,
			activity.Streams["stdout"].Metadata.Size,
			activity.Streams["stderr"].Metadata.Size,
			activity.Streams["env"].Metadata.Size))
	} else {
		table.Add("Streams:", "")
	}
	table.Add("DetailedStatus:", fmt.Sprintf("\"%s\"", activity.DetailedStatus))
	table.Print()
}
开发者ID:andreaturli,项目名称:brooklyn-cli,代码行数:33,代码来源:activity.go

示例15: SetValue

func (b *Balance) SetValue(amount float64) {
	b.Value = amount
	b.Value = utils.Round(b.GetValue(), globalRoundingDecimals, utils.ROUNDING_MIDDLE)
	b.dirty = true

	// publish event
	accountId := ""
	allowNegative := ""
	disabled := ""
	if b.account != nil {
		accountId = b.account.Id
		allowNegative = strconv.FormatBool(b.account.AllowNegative)
		disabled = strconv.FormatBool(b.account.Disabled)
	}
	Publish(CgrEvent{
		"EventName":            utils.EVT_ACCOUNT_BALANCE_MODIFIED,
		"Uuid":                 b.Uuid,
		"Id":                   b.Id,
		"Value":                strconv.FormatFloat(b.Value, 'f', -1, 64),
		"ExpirationDate":       b.ExpirationDate.String(),
		"Weight":               strconv.FormatFloat(b.Weight, 'f', -1, 64),
		"DestinationIds":       b.DestinationIds,
		"RatingSubject":        b.RatingSubject,
		"Category":             b.Category,
		"SharedGroup":          b.SharedGroup,
		"TimingIDs":            b.TimingIDs,
		"Account":              accountId,
		"AccountAllowNegative": allowNegative,
		"AccountDisabled":      disabled,
	})
}
开发者ID:nikbyte,项目名称:cgrates,代码行数:31,代码来源:balances.go


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