當前位置: 首頁>>代碼示例>>Golang>>正文


Golang color.White函數代碼示例

本文整理匯總了Golang中github.com/fatih/color.White函數的典型用法代碼示例。如果您正苦於以下問題:Golang White函數的具體用法?Golang White怎麽用?Golang White使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了White函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: parseGauges

func parseGauges(info string) map[string]int64 {
	gauges_with_values := map[string]int64{
		"blocked_clients":           0,
		"connected_clients":         0,
		"instantaneous_ops_per_sec": 0,
		"latest_fork_usec":          0,
		"mem_fragmentation_ratio":   0,
		"migrate_cached_sockets":    0,
		"pubsub_channels":           0,
		"pubsub_patterns":           0,
		"uptime_in_seconds":         0,
		"used_memory":               0,
		"used_memory_lua":           0,
		"used_memory_peak":          0,
		"used_memory_rss":           0,
	}
	color.White("-------------------")
	color.White("GAUGES:")
	for gauge, _ := range gauges_with_values {
		r, _ := regexp.Compile(fmt.Sprint(gauge, ":([0-9]*)"))
		matches := r.FindStringSubmatch(info)
		if matches == nil {
			color.Yellow(fmt.Sprint("WARN: ", gauge, "is not displayed in redis info"))
		} else {
			value := matches[len(matches)-1]
			color.Cyan(fmt.Sprint(gauge, ": ", value))
			v, _ := strconv.ParseInt(value, 10, 64)
			gauges_with_values[gauge] = v
		}
	}
	return gauges_with_values
}
開發者ID:feelobot,項目名稱:stadis,代碼行數:32,代碼來源:stadis.go

示例2: parseCounters

func parseCounters(info string) map[string]int64 {
	counters := map[string]int64{
		"evicted_keys":               0,
		"expired_keys":               0,
		"keyspace_hits":              0,
		"keyspace_misses":            0,
		"rejected_connections":       0,
		"sync_full":                  0,
		"sync_partial_err":           0,
		"sync_partial_ok":            0,
		"total_commands_processed":   0,
		"total_connections_received": 0,
	}
	color.White("-------------------")
	color.White("COUNTERS:")
	for counter, _ := range counters {
		r, _ := regexp.Compile(fmt.Sprint(counter, ":([0-9]*)"))
		matches := r.FindStringSubmatch(info)
		if matches == nil {
			color.Yellow(fmt.Sprint("ERROR: ", counter, "is not displayed in redis info"))
		} else {
			value := matches[len(matches)-1]
			color.Cyan(fmt.Sprint(counter, ": ", value))
			v, _ := strconv.ParseInt(value, 10, 64)
			counters[counter] = v
		}
	}
	return counters
}
開發者ID:feelobot,項目名稱:stadis,代碼行數:29,代碼來源:stadis.go

示例3: endNotice

func endNotice() {
	fmt.Print("\n\n")
	color.Green("******")
	color.Green("Download complete!\n")
	color.White("Your files have been saved to " + setDownloadFolder() + "\n\n")
	color.White("For your convenience, your files have been sorted by extension.")
	color.Green("******")
}
開發者ID:LadyDascalie,項目名稱:4tools,代碼行數:8,代碼來源:main.go

示例4: startNotice

func startNotice() {
	color.Green("******")
	color.Green("~ Notice: ~\n")
	color.White("When your download is complete,\nyou will find your files under:\n")
	color.Magenta(setDownloadFolder())
	color.Green("******" + "\n\n")
}
開發者ID:LadyDascalie,項目名稱:4tools,代碼行數:7,代碼來源:main.go

示例5: Info

// Info is a convenience method appending a info style message to the logger
func Info(obj interface{}) {
	// Get the line number and calling func sig
	_, fn, line, _ := runtime.Caller(1)
	msg := fmt.Sprintf("%+v\n%s:%d\n\n", obj, fn, line)
	formattedMessage := formattedLogMessage("INFO", msg)
	color.White(formattedMessage)
}
開發者ID:meshhq,項目名稱:gohttp,代碼行數:8,代碼來源:meshLog.go

示例6: getSearchOpt

//
// required for serach options
//
func getSearchOpt() (SearchType, FilterType) {
	var (
		search SearchType = SearchBySubject
		filter FilterType = SearchFilterAll
	)

	for {
		color.White("Please select search range:\n")
		for k := SearchFilterAll; k <= SearchConference; k++ {
			fmt.Fprintf(color.Output, "\t %s: %s\n", color.CyanString("%d", k), searchFilterHints[k])
		}

		fmt.Fprintf(color.Output, "$ %s", color.CyanString("select: "))
		s := getInputString()
		if len(s) > 0 {
			selected, err := strconv.ParseInt(s, 16, 32)
			if err != nil || selected < int64(SearchFilterAll) || selected > int64(SearchConference) {
				color.Red("Invalid selection\n")
				continue
			}

			filter = FilterType(selected)
		}

		break
	}

	return search, filter
}
開發者ID:XMUCCF,項目名稱:cnki-downloader,代碼行數:32,代碼來源:main.go

示例7: Infof

// Infof is a convenience method appending a info style message to the logger
func Infof(msg string, a ...interface{}) {
	_, fn, line, _ := runtime.Caller(1)
	msg = fmt.Sprintf(msg, a...)
	msg = fmt.Sprintf("%+v%s:%d\n\n", msg, fn, line)
	formattedMessage := formattedLogMessage("INFO", msg)
	color.White(formattedMessage)
}
開發者ID:meshhq,項目名稱:gohttp,代碼行數:8,代碼來源:meshLog.go

示例8: writeInfo

func writeInfo(format string, a ...interface{}) {
	if silent {
		return
	}

	color.White(format, a...)
}
開發者ID:getcarina,項目名稱:dvm,代碼行數:7,代碼來源:util.go

示例9: monitor

func monitor(hostname string, interval int, changes chan<- string) {
	var knownAddresses []string
	for tick := range time.NewTicker(time.Duration(interval) * time.Second).C {
		addresses := lookup(hostname)
		color.White("[LOOKUP] %s %s %s", hostname, addresses, tick)
		if !equivalent(knownAddresses, addresses) {
			changes <- hostname
			knownAddresses = addresses
		}
	}
}
開發者ID:stevenharradine,項目名稱:dns-reactor,代碼行數:11,代碼來源:dns-reactor.go

示例10: connect

// conect to server operation
func connect(matched []Server, printOnly bool) {
	if len(matched) == 0 {
		color.Cyan("No server match patterns")
	} else if len(matched) == 1 {
		color.Green("%s", matched[0].getConnectionString())
		if !printOnly {
			matched[0].connect()
		}
	} else {
		color.Cyan("Multiple servers match patterns:")
		for _, s := range matched {
			color.White(s.getConnectionString())
		}
	}
}
開發者ID:danielkraic,項目名稱:gsh,代碼行數:16,代碼來源:operations.go

示例11: download

// download file from server operation
func download(src string, dest string, matched []Server, printOnly bool) {
	if len(matched) == 0 {
		color.Cyan("No server match patterns")
	} else if len(matched) == 1 {
		color.Green("%s", matched[0].getDownloadString(src, dest))
		if !printOnly {
			matched[0].download(src, dest)
		}
	} else {
		color.Cyan("Multiple servers match patterns:")
		for _, s := range matched {
			color.White(s.getDownloadString(src, dest))
		}
	}
}
開發者ID:danielkraic,項目名稱:gsh,代碼行數:16,代碼來源:operations.go

示例12: workspaces_list

func workspaces_list(c *cli.Context) error {
	max := c.Int("max")
	url := c.GlobalString("url")
	if url == "" {
		return cli.NewExitError("A URL must be provided with the SCALE_URL environment variable or the --url argument", 1)
	}
	workspaces, err := scalecli.GetWorkspaceList(url, max)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	for _, workspace := range workspaces {
		if workspace.Is_active {
			color.Green(workspace.String())
		} else {
			color.White(workspace.String())
		}
	}
	return nil
}
開發者ID:ngageoint,項目名稱:scale,代碼行數:19,代碼來源:workspaces.go

示例13: main

func main() {
	// init
	app := cli.NewApp()
	app.Name = "stadis"
	app.Version = "0.0.2"
	app.Usage = "get redis info and submit to statsd"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "redis-host, r",
			Value: "localhost:6379",
			Usage: "host:port of redis servier",
		},
		cli.StringFlag{
			Name:  "statsd-host, s",
			Value: "localhost:8125",
			Usage: "host:port of statsd servier",
		},
		cli.StringFlag{
			Name:   "prefix,p",
			Usage:  "host:port of redis servier",
			EnvVar: "HOSTNAME",
		},
		cli.StringFlag{
			Name:  "interval,i",
			Usage: "time in milliseconds to periodically check redis",
			Value: "5000",
		},
	}
	app.Action = func(c *cli.Context) {
		for {
			info := getStats(c.String("redis-host"))
			gauges := parseGauges(info)
			counters := parseCounters(info)
			sendStats(c.String("statsd-host"), c.String("prefix"), gauges, counters)
			color.White("-------------------")
			interval, _ := strconv.ParseInt(c.String("interval"), 10, 64)
			time.Sleep(time.Duration(interval) * time.Millisecond)
		}
	}
	app.Run(os.Args)
}
開發者ID:feelobot,項目名稱:stadis,代碼行數:41,代碼來源:stadis.go

示例14: jobs_validate

func jobs_validate(c *cli.Context) error {
	var job_type scalecli.JobType
	err := Parse_json_or_yaml("job_type", &job_type)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}

	url := c.GlobalString("url")
	if url == "" {
		return cli.NewExitError("A URL must be provided with the SCALE_URL environment variable or the --url argument", 1)
	}
	warnings, err := scalecli.ValidateJobType(url, job_type)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	if warnings == "" {
		color.White("Job type specification is valid.")
	} else {
		color.Yellow(warnings)
	}
	return nil
}
開發者ID:ngageoint,項目名稱:scale,代碼行數:22,代碼來源:jobs.go

示例15: main

func main() {
	flag.Parse()

	if *sitemapURL == "" {
		fmt.Println("-sitemap に sitemap.xml/.xml.gz のURLを指定してください")
		return
	}

	smap, err := sitemap.Get(*sitemapURL)
	if err != nil {
		fmt.Println(err)
	}

	for _, URL := range smap.URL {
		time.Sleep(time.Second)

		resp, err := http.Get(URL.Loc)
		if err != nil {
			fmt.Println(err)
			continue
		}
		defer resp.Body.Close()
		switch statusType(resp.StatusCode) {
		case 100:
			color.Cyan(resp.Status + " " + URL.Loc)
		case 200:
			color.Green(resp.Status + " " + URL.Loc)
		case 300:
			color.Magenta(resp.Status + " " + URL.Loc)
		case 400:
			color.Red(resp.Status + " " + URL.Loc)
		case 500:
			color.Yellow(resp.Status + " " + URL.Loc)
		default:
			color.White(resp.Status + " " + URL.Loc)
		}
	}
}
開發者ID:yterajima,項目名稱:sitemap-check,代碼行數:38,代碼來源:main.go


注:本文中的github.com/fatih/color.White函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。