本文整理汇总了Golang中github.com/wsxiaoys/terminal/color.Print函数的典型用法代码示例。如果您正苦于以下问题:Golang Print函数的具体用法?Golang Print怎么用?Golang Print使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Print函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: main
func main() {
reader := bufio.NewReader(os.Stdin)
for {
color.Print("@b>> ")
words, _ := reader.ReadString('\n')
text, err := request(strings.TrimSpace(words))
if err != nil {
color.Println("@rERROR : ", err)
}
color.Println("@r>> ", text)
}
}
开发者ID:ashora,项目名称:talk,代码行数:15,代码来源:main.go
示例17: ServeHTTP
func (s *LoggingServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
s.mu.RLock()
defer s.mu.RUnlock()
if i := sort.SearchStrings(s.ExcludePaths, req.URL.Path); i < len(s.ExcludePaths) && req.URL.Path == s.ExcludePaths[i] {
return
}
req.ParseForm()
// Log request
var data string
for key, _ := range req.Form {
data += "\n "
if value := req.Form.Get(key); value != "" {
data += color.Sprintf("@.%[email protected]|@w = @|%s", key, value)
} else {
data += color.Sprintf("%s", key)
}
}
log.Print(color.Sprintf("@c%s @{!y}%s", req.Method, req.RequestURI))
if data != "" {
color.Printf(" @[email protected]|%s\n", data)
}
// Find matcher
matcher := s.findMatcher(req)
if matcher != nil {
matcher.Write(w, req)
// TODO Better response logging
response := matcher.Response
color.Printf(" @[email protected]|\n %+v\n", response)
} else {
color.Print(" @[email protected]|\n")
w.WriteHeader(http.StatusNotFound)
w.Header().Set("Content-Type", "text/html")
io.WriteString(w, "<html><body>Unmatched request, please configure a mock request for path "+req.URL.Path+" and method "+req.Method+"</body></html>\n")
}
}
开发者ID:hlubek,项目名称:logging-server,代码行数:42,代码来源:server.go
示例18: Run
// Main command method
func (c *AddItemCommand) Run() error {
category := &models.Category{}
err := category.FindCategoryOrCreate(map[string]interface{}{
"title": c.CategoryTitle,
"type": c.ItemType,
}).Error
if err != nil {
return err
}
item := models.NewItem(db.USERID, category.Id, c.ItemType,
c.Comment, c.Amount)
err = item.Save().Error
if err != nil {
return err
}
color.Print("@gItem [email protected]{|}\n")
return nil
}
开发者ID:4gophers,项目名称:karman-cli,代码行数:22,代码来源:add_item_command.go
示例19: Run
// Main command method
func (c *EditItemCommand) Run() error {
var item models.Item
item.Find(c.Id)
if item.Id == 0 {
return errors.New("Invalid Item Id")
}
if c.Amount != 0 {
item.Amount = c.Amount
}
if c.ItemType != "" {
item.Type = c.ItemType
}
if c.Comment != "" {
item.Comment = c.Comment
}
if c.CategoryTitle != "" {
category := &models.Category{}
err := category.FindCategoryOrCreate(map[string]interface{}{
"title": c.CategoryTitle,
"type": item.Type,
}).Error
if err != nil {
return err
}
item.CategoryId = category.Id
}
err := item.Save().Error
if err != nil {
return err
}
color.Print("@gItem edited\n")
return nil
}
开发者ID:4gophers,项目名称:karman-cli,代码行数:40,代码来源:edit_item_command.go
示例20: Run
func (c *EditCategoryCommand) Run() error {
category := &models.Category{}
category.Find(c.Id)
if category.Id == 0 {
return errors.New("Category not found")
}
if c.Title != "" {
category.Title = c.Title
}
if c.CategoryType != "" {
category.Type = c.CategoryType
}
err := category.Save().Error
if err != nil {
return err
}
color.Print("@gCategory edited\n")
return nil
}
开发者ID:4gophers,项目名称:karman-cli,代码行数:23,代码来源:edit_category_command.go
注:本文中的github.com/wsxiaoys/terminal/color.Print函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论