Limit number of concurrent goroutines
This commit is contained in:
parent
5fd9bc851b
commit
62dadc53bf
12 changed files with 206 additions and 103 deletions
22
echo/echo.go
22
echo/echo.go
|
|
@ -7,11 +7,11 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
colorReset = "\033[0m"
|
||||
colorRed = "\033[31m"
|
||||
colorGreen = "\033[32m"
|
||||
colorYellow = "\033[33m"
|
||||
colorBlue = "\033[34m"
|
||||
ColorReset = "\033[0m"
|
||||
ColorRed = "\033[31m"
|
||||
ColorGreen = "\033[32m"
|
||||
ColorYellow = "\033[33m"
|
||||
ColorBlue = "\033[34m"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -30,7 +30,7 @@ func Output(writer io.Writer) {
|
|||
func ErrorfMsg(format string, a ...interface{}) error {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
if useColor {
|
||||
msg = fmt.Sprintf("%vError:%v %v", colorRed, colorReset, msg)
|
||||
msg = fmt.Sprintf("%vError:%v %v", ColorRed, ColorReset, msg)
|
||||
} else {
|
||||
msg = fmt.Sprintf("Error: %v", msg)
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ func ErrorfMsg(format string, a ...interface{}) error {
|
|||
func InfoFMsg(format string, a ...interface{}) error {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
if useColor {
|
||||
msg = fmt.Sprintf("%vInfo:%v %v", colorBlue, colorReset, msg)
|
||||
msg = fmt.Sprintf("%vInfo:%v %v", ColorBlue, ColorReset, msg)
|
||||
} else {
|
||||
msg = fmt.Sprintf("Info: %v", msg)
|
||||
}
|
||||
|
|
@ -48,19 +48,19 @@ func InfoFMsg(format string, a ...interface{}) error {
|
|||
}
|
||||
|
||||
func GreenMessageF(format string, a ...interface{}) error {
|
||||
return writeWithColor(fmt.Sprintf(format, a...), colorGreen)
|
||||
return writeWithColor(fmt.Sprintf(format, a...), ColorGreen)
|
||||
}
|
||||
|
||||
func YellowMessageF(format string, a ...interface{}) error {
|
||||
return writeWithColor(fmt.Sprintf(format, a...), colorYellow)
|
||||
return writeWithColor(fmt.Sprintf(format, a...), ColorYellow)
|
||||
}
|
||||
func RedMessageF(format string, a ...interface{}) error {
|
||||
return writeWithColor(fmt.Sprintf(format, a...), colorRed)
|
||||
return writeWithColor(fmt.Sprintf(format, a...), ColorRed)
|
||||
}
|
||||
|
||||
func writeWithColor(msg string, color string) error {
|
||||
if useColor {
|
||||
return write(fmt.Sprintf("%v%v%v", color, msg, colorReset))
|
||||
return write(fmt.Sprintf("%v%v%v", color, msg, ColorReset))
|
||||
}
|
||||
return write(msg)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue