本文整理汇总了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)
}
}
示例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()
}
}
示例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])
}
}
}
示例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)
}
}
示例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
}
示例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()
}
示例7: Info
func (logger *Logger) Info(msgs ...interface{}) {
if isTestEnv() {
logger.infos = append(logger.infos, msgs...)
return
}
color.Print(msgs...)
}
示例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))
}
示例9: main
func main() {
terminal.Stdout.Color("y").
Print("Hello world").Nl().
Reset().
Colorf("@{kW}Hello world\n")
color.Print("@rHello world")
}
示例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...)
}
示例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()
}
示例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)
}
示例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
}
示例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
}
示例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
}