当前位置: 首页>>代码示例>>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;未经允许,请勿转载。