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


Golang color.Cyan函數代碼示例

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


在下文中一共展示了Cyan函數的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: 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


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