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


Golang color.Print函數代碼示例

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


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

示例1: oneDomainCheck

func oneDomainCheck(domain string, flagShowFreeOnly bool) {
	checkedDomain, isFree := check(domain)
	if isFree == true {
		color.Print("@g[FREE]", checkedDomain)
	} else if flagShowFreeOnly == false {
		color.Print("@r[NOT FREE]", checkedDomain)
	}
}
開發者ID:shalakhin,項目名稱:dodo,代碼行數:8,代碼來源:dodo.go

示例2: showNewsList

func showNewsList(news []Item) {
	for i, item := range news {
		color.Print("@b", fmt.Sprintf("%2d", i+1))
		fmt.Print(" ")
		color.Print("@{!g}", item.Title)
		fmt.Print(" ")
		color.Print("@y", fmt.Sprintf("%dc", item.CommentsCount))
		fmt.Print(" ")
		color.Print("@m", fmt.Sprintf("%dp", item.Points))
		fmt.Print(" ")
		color.Print("@w", item.Domain)
		fmt.Println()
	}
}
開發者ID:anykao,項目名稱:p,代碼行數:14,代碼來源:hn.go

示例3: handle

func handle(file string) {
	filename, err := os.Open(file)
	defer filename.Close()
	if err != nil {
		log.Fatal(err)
	}
	scanner := bufio.NewScanner(filename)
	var domains []string
	for scanner.Scan() {
		domain, isFree := check(scanner.Text())
		if isFree == true {
			domains = append(domains, domain)
		} else if showFreeOnly == false {
			domains = append(domains, domain)
		}
	}
	sort.Strings(domains)
	for i := 0; i < len(domains); i++ {
		if showFreeOnly == true {
			color.Print("@g[FREE]", domains[i])
		} else {
			fmt.Print(domains[i])
		}
	}
}
開發者ID:shalakhin,項目名稱:dodo,代碼行數:25,代碼來源:dodo.go

示例4: log

func (msg *message) log(elapsed time.Duration) {
	if fmtstr := formatFor(msg.namespace); fmtstr != "" {
		payload := fmt.Sprintf(msg.message, msg.args...)
		content := fmt.Sprintf(fmtstr, msg.from_file, msg.from_line, payload, elapsed)
		colorfmt.Print(content)
	}
}
開發者ID:dokipen,項目名稱:gocollect,代碼行數:7,代碼來源:debug.go

示例5: getFuncNames

func getFuncNames(filecontent []string) ([]string, []string) {
	r := make([]string, 0)
	r2 := make([]string, 0)
	var funcCounter int64
	functionRx := regexp.MustCompile(FUNCTION_NAME_REGEX)
	functionDefRx := regexp.MustCompile(FUNCTION_DEFINITION_REGEX)
	for lineno, line := range filecontent {
		if functionRx.MatchString(line) {
			funcnameB := functionRx.FindSubmatch([]byte(line))
			funcname := string(funcnameB[1])
			funcCounter = funcCounter + 1
			fmt.Printf("%v %d ", funcCounter, lineno)
			color.Print("@g", funcname)
			color.Println("@y|", line)
			r = append(r, funcname)

			if functionDefRx.MatchString(line) {
				funcdefB := functionDefRx.FindSubmatch([]byte(line))
				funcdef := string(funcdefB[1])
				r2 = append(r2, funcdef)
			} else {
				log.Fatal("Can detect the funciton name but not the function definition! That is not acceptable")
			}
		}
	}
	return r, r2
}
開發者ID:alimoeeny,項目名稱:BGCMatlab,代碼行數:27,代碼來源:convert.go

示例6: prettyPrint

func prettyPrint(repo github.Repository, index int) {
	fmt.Print("[")
	color.Print("@b", index)
	fmt.Print("]")
	fmt.Print(*repo.FullName)
	if repo.StargazersCount != nil {
		color.Print("@r"+" "+strconv.Itoa(*repo.StargazersCount), "☆")
	}
	if repo.Language != nil {
		color.Print("@c" + " " + *repo.Language)
	}
	if repo.Description != nil {
		color.Print("@g" + " " + *repo.Description)
	}
	fmt.Println()
}
開發者ID:anykao,項目名稱:p,代碼行數:16,代碼來源:gh.go

示例7: Info

func (logger *Logger) Info(msgs ...interface{}) {
	if isTestEnv() {
		logger.infos = append(logger.infos, msgs...)
		return
	}

	color.Print(msgs...)
}
開發者ID:linearregression,項目名稱:git-hooks,代碼行數:8,代碼來源:logger.go

示例8: LogMessage

func LogMessage(message string, textColor string) {
	msg := fmt.Sprintf("%v", message)
	var c string
	if textColor != "" {
		c = fmt.Sprintf("@%v", textColor)
	}
	color.Print(c, fmt.Sprintf(" %v\n", msg))
}
開發者ID:vyctorbh,項目名稱:shipyard-cli,代碼行數:8,代碼來源:utils.go

示例9: main

func main() {
	terminal.Stdout.Color("y").
		Print("Hello world").Nl().
		Reset().
		Colorf("@{kW}Hello world\n")

	color.Print("@rHello world")
}
開發者ID:ateleshev,項目名稱:terminal,代碼行數:8,代碼來源:hello.go

示例10: Warn

func (logger *Logger) Warn(msgs ...interface{}) {
	if isTestEnv() {
		logger.warns = append(logger.warns, msgs...)
		return
	}

	msgs = append([]interface{}{"@y"}, msgs...)
	color.Print(msgs...)
}
開發者ID:linearregression,項目名稱:git-hooks,代碼行數:9,代碼來源:logger.go

示例11: Draw

// Draw all Cell structures
func (game *Game) Draw() {
	clearScreen()

	fmt.Printf("Generation : %v\n", game.Generation)

	for _, r := range game.Rows {
		for _, c := range r.Cells {
			if c.Value == 1 {
				color.Print(fmt.Sprintf("%v ", c.Color))
			} else {
				color.Print("@c.")
			}
		}
		fmt.Printf("\n")
	}

	game.Sleep()
}
開發者ID:scottjbarr,項目名稱:gameoflife-go,代碼行數:19,代碼來源:main.go

示例12: Errors

func (logger *Logger) Errors(status int, msgs ...interface{}) {
	if isTestEnv() {
		logger.errors = append(logger.errors, msgs...)
		return
	}

	msgs = append([]interface{}{"@r"}, msgs...)
	color.Print(msgs...)
	os.Exit(status)
}
開發者ID:linearregression,項目名稱:git-hooks,代碼行數:10,代碼來源:logger.go

示例13: Run

func (c *AddCategoryCommand) Run() error {
	c.Slug = c.Title
	category := models.NewCategory(db.USERID, c.CategoryType, c.Title, c.Slug)
	err := category.Save().Error
	if err != nil {
		return err
	}

	color.Print("@gCategory added{|}\n")
	return nil
}
開發者ID:4gophers,項目名稱:karman-cli,代碼行數:11,代碼來源:add_category_command.go

示例14: Run

func (c *DeleteItemCommand) Run() error {
	item := models.Item{}
	item.Find(item.Id)

	if item.Id == 0 {
		return errors.New("Inavlid id")
	}

	err := item.Delete().Error
	if err != nil {
		return err
	}
	color.Print("@gItem deleted\n")
	return nil
}
開發者ID:4gophers,項目名稱:karman-cli,代碼行數:15,代碼來源:delete_item_command.go

示例15: Run

func (c *DeleteCategoryCommand) Run() error {
	category := models.Category{}
	category.Find(c.Id)

	if category.Id == 0 {
		return errors.New("Inavlid id")
	}

	err := category.Delete().Error
	if err != nil {
		return err
	}
	color.Print("@gCategory deleted\n")
	return nil
}
開發者ID:4gophers,項目名稱:karman-cli,代碼行數:15,代碼來源:delete_category_command.go


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