• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang color.Cyan函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Cyan函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: Start

func Start() {
	if os.Getenv("IMGSTORAGE_LOCATION") != "" {
		ImgStoragePath = os.Getenv("IMGSTORAGE_LOCATION")
	} else {
		reader := bufio.NewReader(os.Stdin)
		color.Cyan("Enter location of image storage: ")
		ImgStoragePath, _ = reader.ReadString('\n')
	}
	cio.PrintMessage(1, "Image storage is being created...")
	if _, err := os.Stat(ImgStoragePath); os.IsNotExist(err) {
		// doesn't exist
		os.Mkdir(ImgStoragePath, 0776)
		cio.PrintMessage(2, (ImgStoragePath + " created."))
	} else {
		cio.PrintMessage(2, (ImgStoragePath + " already existed."))
	}

	if os.Getenv("IMG_NAME_LENGTH") != "" {
		ImgNameLength, _ = strconv.Atoi(os.Getenv("IMG_NAME_LENGTH"))
	} else {
		reader := bufio.NewReader(os.Stdin)
		color.Cyan("Enter length of image names: ")
		temp, _ := reader.ReadString('\n')
		ImgNameLength, _ = strconv.Atoi(temp)
	}
}
开发者ID:mkocs,项目名称:pixmate-server,代码行数:26,代码来源:fsys.go


示例3: main

// TEST="asdf,asdf,asdf" ./main template.tpl
func main() {

	if len(os.Args) != 2 {
		color.Red("tenv: v.01")
		color.Blue("------------------------")
		color.Cyan("Prepopulates to stdin given template with information stored in env variables")
		color.Cyan("variables should follow go template syntax {{.VAR_NAME}}")
		color.Cyan("and must be declared on the environment")
		color.Cyan("Usage : tenv filename")
		os.Exit(1)
	}
	var funcMap template.FuncMap
	funcMap = template.FuncMap{
		"split": strings.Split,
	}

	file := filepath.Base(os.Args[1])

	t, err := template.New(file).Funcs(funcMap).ParseFiles(os.Args[1])
	if err != nil {
		log.Fatalf("Error: %s", err)
	}

	context := make(map[string]string)
	for _, v := range os.Environ() {
		p := strings.Split(v, "=")
		context[p[0]] = p[1]
	}

	err = t.ExecuteTemplate(os.Stdout, file, context)
	if err != nil {
		log.Fatal(err)
	}

}
开发者ID:jordic,项目名称:tenv,代码行数:36,代码来源:main.go


示例4: Start

// Start is the database package launch method
// it enters or fetches the data required for the database
func Start() {
	/*
	 * allow user to enter db data
	 * used instead of environment variables
	 * if there are none
	 * since the service is open source
	 */
	var (
		uname string
		pw    string
		name  string
	)
	if os.Getenv("DB_UNAME") == "" && os.Getenv("DB_NAME") == "" {
		reader := bufio.NewReader(os.Stdin)
		color.Cyan("Enter db user name: ")
		uname, _ = reader.ReadString('\n')

		color.Cyan("Enter db pw: ")
		pw, _ = reader.ReadString('\n')

		color.Cyan("Enter db name: ")
		name, _ = reader.ReadString('\n')
	} else {
		uname = os.Getenv("DB_UNAME")
		pw = os.Getenv("DB_PW")
		name = os.Getenv("DB_NAME")
	}
	var err error
	db, err = sql.Open("postgres",
		"user="+uname+
			" password="+pw+
			" dbname="+name+
			" sslmode=disable")

	if err != nil {
		cio.PrintMessage(1, err.Error())
		return
	}
	// test connection
	err = db.Ping()
	if err != nil { // connection not successful
		cio.PrintMessage(1, err.Error())
		var rundb string
		reader := bufio.NewReader(os.Stdin)
		color.Cyan("Do you want to run the server without a working database module? (y/n) ")
		rundb, _ = reader.ReadString('\n')
		if rundb != "y\n" && rundb != "Y\n" {
			os.Exit(-1)
		}
	}
}
开发者ID:mkocs,项目名称:pixmate-server,代码行数:53,代码来源:db.go


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


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


示例7: TesTFetchingJob

func TesTFetchingJob(t *testing.T) {

	out, _ := jobworker.FetchJob("parsebin")

	color.Cyan(out)

}
开发者ID:rohanraja,项目名称:jobworker,代码行数:7,代码来源:redis_test.go


示例8: Build

// Build listens watch events from Watcher and sends messages to Runner
// when new changes are built.
func (b *Builder) Build(p *Params) {
	go b.registerSignalHandler()
	go func() {
		b.watcher.update <- true
	}()

	for <-b.watcher.Wait() {
		fileName := p.createBinaryName()

		pkg := p.GetPackage()

		color.Cyan("Building %s...\n", pkg)

		// build package
		cmd, err := runCommand("go", "build", "-o", fileName, pkg)
		if err != nil {
			log.Fatalf("Could not run 'go build' command: %s", err)
			continue
		}

		if err := cmd.Wait(); err != nil {
			if err := interpretError(err); err != nil {
				color.Red("An error occurred while building: %s", err)
			} else {
				color.Red("A build error occurred. Please update your code...")
			}

			continue
		}

		// and start the new process
		b.runner.restart(fileName)
	}
}
开发者ID:rwuebker,项目名称:go-watcher,代码行数:36,代码来源:build.go


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


示例10: writeDebug

func writeDebug(format string, a ...interface{}) {
	if !debug {
		return
	}

	color.Cyan(format, a...)
}
开发者ID:getcarina,项目名称:dvm,代码行数:7,代码来源:util.go


示例11: TesTGettingJobInfo

func TesTGettingJobInfo(t *testing.T) {

	jid := jobworker.GetPendingJids("parsebin")

	out := jobworker.GetJobInfo("parsebin", jid)

	color.Cyan(out)

}
开发者ID:rohanraja,项目名称:jobworker,代码行数:9,代码来源:redis_test.go


示例12: PrintMessage

func PrintMessage(cl int, msg string) {
	if cl == 0 {
		color.Green("[pixmate] %s", msg)
	} else if cl == 1 {
		color.Red("[pixmate] %s", msg)
	} else if cl == 2 {
		color.Cyan("[pixmate] %s", msg)
	}
}
开发者ID:mkocs,项目名称:pixmate-server,代码行数:9,代码来源:io.go


示例13: Usage

func (this *Options) Usage() {
	var banner string = ` ____            _
|  _ \ ___ _ __ | | __ _  ___ ___
| |_) / _ \ '_ \| |/ _' |/ __/ _ \
|  _ <  __/ |_) | | (_| | (_|  __/
|_| \_\___| .__/|_|\__'_|\___\___|
          |_|

`
	color.Cyan(banner)
	flag.Usage()
}
开发者ID:nomad-software,项目名称:replace,代码行数:12,代码来源:options.go


示例14: Do

// Do accepts a function argument that returns an error. It will keep executing this
// function NumRetries times until no error is returned.
// Optionally pass another function as an argument that it will execute before retrying
// in case an error is returned from the first argument fuction.
func Do(args ...interface{}) error {

	if len(args) == 0 {
		panic("Wrong number of arguments")
	}

	task, ok := args[0].(func() error)

	beforeRetry := func() {}
	if len(args) > 1 {
		beforeRetry, ok = args[1].(func())
	}

	if ok == false {
		panic("Wrong Type of Arguments given to retry.Do")
	}

	retries := NumRetries

	var atleastOneError error
	atleastOneError = nil

	err := errors.New("Non-Nil error")
	for retries > 0 && err != nil {

		err = task()

		if err != nil {
			atleastOneError = err
			color.Magenta("\nError: %v\nRetrying #%d after %v", err, (NumRetries - retries + 1), Delay)
			time.Sleep(Delay)
			beforeRetry()
		}

		retries = retries - 1
	}

	if err != nil {

		color.Red("\nError even after %d retries:\n%v", NumRetries, err)
		if PanicEnabled == true {
			panic(err)
		}
		return err
	}

	if atleastOneError != nil {
		color.Cyan("\nRecovered from error: %v in %d tries\n", atleastOneError, (NumRetries - retries - 1))
	}

	return err

}
开发者ID:rohanraja,项目名称:retry,代码行数:57,代码来源:retry.go


示例15: show

func show(dict Dict) {
	for _, ps := range dict.Ps {
		color.Green(ps)
	}
	for index, pos := range dict.Pos {
		color.Red(strings.TrimSpace(pos))
		color.Yellow(strings.TrimSpace(dict.Acceptation[index]))
	}
	for _, sent := range dict.SentList {
		color.Blue("ex. %s", strings.TrimSpace(sent.Orig))
		color.Cyan("    %s", strings.TrimSpace(sent.Trans))
	}
}
开发者ID:Flowerowl,项目名称:ici.go,代码行数:13,代码来源:ici.go


示例16: printSSHKeys

func printSSHKeys(v *vaulted.Vault) {
	color.Cyan("\nSSH Keys:")
	if len(v.SSHKeys) > 0 {
		keys := []string{}
		for key := range v.SSHKeys {
			keys = append(keys, key)
		}
		sort.Strings(keys)

		for _, key := range keys {
			green.Printf("  %s\n", key)
		}
	} else {
		print("  [Empty]")
	}
}
开发者ID:daveadams,项目名称:vaulted,代码行数:16,代码来源:edit.go


示例17: main

func main() {
	url := flag.String("url", "", "webservice url")
	count := flag.Int("count", 1, "requests count")
	stats := flag.Bool("stats", false, "print stats only")
	method := flag.String("method", "GET", "http method (POST or GET)")

	flag.Parse()

	if len(*url) == 0 {
		fmt.Println("Missing param url")
		return
	}

	httpFunc := get
	if *method == "POST" {
		httpFunc = post
	}

	responses := make(chan int, *count)
	for i := 0; i < *count; i++ {
		go httpFunc(responses, *url)
	}

	respMap := make(map[int]int)
	for i := 0; i < *count; i++ {
		statusCode := <-responses
		respMap[statusCode]++

		if *stats {
			continue
		}

		statusMsg := fmt.Sprintf("%d :: %d", i, statusCode)

		if statusCode != 200 {
			color.Red(statusMsg)
		} else {
			color.Cyan(statusMsg)
		}
	}

	if *stats {
		for k, v := range respMap {
			fmt.Printf("%d :: %-5d\n", k, v)
		}
	}
}
开发者ID:danielkraic,项目名称:webservice-testing,代码行数:47,代码来源:webservice-test.go


示例18: printVariables

func printVariables(v *vaulted.Vault) {
	color.Cyan("\nVariables:")
	if len(v.Vars) > 0 {
		var keys []string
		for key := range v.Vars {
			keys = append(keys, key)
		}
		sort.Strings(keys)

		for _, key := range keys {
			green.Printf("  %s: ", key)
			fmt.Printf("%s\n", v.Vars[key])
		}
	} else {
		print("  [Empty]")
	}
}
开发者ID:daveadams,项目名称:vaulted,代码行数:17,代码来源:edit.go


示例19: promptUserToSelectModule

func promptUserToSelectModule(modules []Module, optional bool) (Module, error) {
	// Prompt the user to select a module.
	kind := modules[0].Kind()

	for {
		// Write the dialog into the console.
		ctx := &dialogTemplateContext{
			Kind:     string(kind),
			Modules:  modules,
			Optional: optional,
		}
		if err := dialogTemplate.Execute(os.Stdout, ctx); err != nil {
			return nil, err
		}

		// Prompt the user for the answer.
		// An empty answer is aborting the dialog.
		answer, err := prompt.Prompt("You choice: ")
		if err != nil {
			if err == prompt.ErrCanceled {
				prompt.PanicCancel()
			}
			return nil, err
		}

		if optional && answer == "s" {
			fmt.Println()
			color.Cyan("Skipping module kind '%v'", kind)
			return nil, nil
		}

		// Parse the index and return the associated module.
		i, err := strconv.Atoi(answer)
		if err == nil {
			if 0 < i && i <= len(modules) {
				return modules[i-1], nil
			}
		}

		// In case we failed to parse the index or something, run the dialog again.
		color.Yellow("Not a valid choice, please try again!")
	}
}
开发者ID:salsaflow,项目名称:salsaflow,代码行数:43,代码来源:dialog.go


示例20: RunRecursively

func RunRecursively(cmd CliCommand) {
	t := time.Now()
	wg := new(sync.WaitGroup)
	pathChan := make(chan vcsPath)
	count := 0

	go findRepositories(".", pathChan)

	for p := range pathChan {
		vcsCmd := cmd.GetVcsCommand(p.Sign)
		if vcsCmd != nil {
			wg.Add(1)
			go execVcsCmd(vcsCmd, p.Path, wg)
			count++
		}
	}

	wg.Wait()
	color.Cyan("Done \"%s\" command for %d repos in %s\n\n", cmd.Name, count, time.Since(t))
}
开发者ID:kulapard,项目名称:go-eatme,代码行数:20,代码来源:runner.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang color.CyanString函数代码示例发布时间:2022-05-23
下一篇:
Golang color.BlueString函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap