Skip to content

Commit 4e7ce07

Browse files
author
myxy99
committed
x
1 parent a39535e commit 4e7ce07

File tree

5 files changed

+18
-41
lines changed

5 files changed

+18
-41
lines changed

xcolor/string_darwin.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1+
// +build darwin
2+
13
package xcolor
24

35
import (
46
"fmt"
5-
"math/rand"
6-
"strconv"
77
)
88

9-
var _ = RandomColor()
10-
11-
// RandomColor generates a random color.
12-
func RandomColor() string {
13-
return fmt.Sprintf("#%s", strconv.FormatInt(int64(rand.Intn(16777216)), 16))
14-
}
15-
169
// Yellow ...
1710
func Yellow(msg string) string {
1811
return fmt.Sprintf("\x1b[33m%s\x1b[0m", msg)

xcolor/string_linux.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1+
// +build linux
2+
13
package xcolor
24

35
import (
46
"fmt"
5-
"math/rand"
6-
"strconv"
77
)
88

9-
var _ = RandomColor()
10-
11-
// RandomColor generates a random color.
12-
func RandomColor() string {
13-
return fmt.Sprintf("#%s", strconv.FormatInt(int64(rand.Intn(16777216)), 16))
14-
}
15-
169
// Yellow ...
1710
func Yellow(msg string) string {
1811
return fmt.Sprintf("\x1b[33m%s\x1b[0m", msg)

xcolor/string_windows.go

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,47 @@
1+
// +build windows
2+
13
package xcolor
24

35
import (
46
"fmt"
5-
"math/rand"
6-
"strconv"
77
)
88

9-
var _ = RandomColor()
10-
11-
// RandomColor generates a random color.
12-
func RandomColor() string {
13-
return fmt.Sprintf("#%s", strconv.FormatInt(int64(rand.Intn(16777216)), 16))
14-
}
15-
169
// Yellow ...
1710
func Yellow(msg string) string {
18-
return fmt.Sprintf("\x1b[33m%s\x1b[0m", msg)
11+
return fmt.Sprintf("%s", msg)
1912
}
2013

21-
// Yellowf ...
14+
// Yellow ...
2215
func Yellowf(msg string, arg interface{}) string {
23-
return fmt.Sprintf("\x1b[33m%s\x1b[0m %+v\n", msg, arg)
16+
return fmt.Sprintf("%s %+v\n", msg, arg)
2417
}
2518

2619
// Red ...
2720
func Red(msg string) string {
28-
return fmt.Sprintf("\x1b[31m%s\x1b[0m", msg)
21+
return fmt.Sprintf("%s", msg)
2922
}
3023

3124
// Redf ...
3225
func Redf(msg string, arg interface{}) string {
33-
return fmt.Sprintf("\x1b[31m%s\x1b[0m %+v\n", msg, arg)
26+
return fmt.Sprintf("%s %+v\n", msg, arg)
3427
}
3528

3629
// Blue ...
3730
func Blue(msg string) string {
38-
return fmt.Sprintf("\x1b[34m%s\x1b[0m", msg)
31+
return fmt.Sprintf("%s", msg)
3932
}
4033

41-
// Bluef ...
34+
// Greenf ...
4235
func Bluef(msg string, arg interface{}) string {
43-
return fmt.Sprintf("\x1b[34m%s\x1b[0m %+v\n", msg, arg)
36+
return fmt.Sprintf("%s %+v\n", msg, arg)
4437
}
4538

4639
// Green ...
4740
func Green(msg string) string {
48-
return fmt.Sprintf("\x1b[32m%s\x1b[0m", msg)
41+
return fmt.Sprintf("%s", msg)
4942
}
5043

5144
// Greenf ...
5245
func Greenf(msg string, arg interface{}) string {
53-
return fmt.Sprintf("\x1b[32m%s\x1b[0m %+v\n", msg, arg)
46+
return fmt.Sprintf("%s %+v\n", msg, arg)
5447
}

xnet/ip.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func GetLocalMainIP() (string, int, error) {
3939
func GetMacAddrs() (macAddrs []string) {
4040
netInterfaces, err := net.Interfaces()
4141
if err != nil {
42-
fmt.Printf("fail to get net interfaces: %v", err)
42+
panic(fmt.Sprintf("fail to get net interfaces: %v", err))
4343
return macAddrs
4444
}
4545

@@ -58,7 +58,7 @@ func GetMacAddrs() (macAddrs []string) {
5858
func GetIPs() (ips []string) {
5959
interfaceAddr, err := net.InterfaceAddrs()
6060
if err != nil {
61-
fmt.Printf("fail to get net interface addrs: %v", err)
61+
panic(fmt.Sprintf("fail to get net interface addrs: %v", err))
6262
return ips
6363
}
6464

xvalidator/xvalidate.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ func GetMsg(err error) *ValidationError {
108108
func NewValidationError(errMap map[string]string) *ValidationError {
109109
res := make([]string, 0)
110110
for _, v := range errMap {
111-
//fmt.Println(k)
112-
//fmt.Println(field[strings.Index(field, ".")+1:])
113111
res = append(res, v)
114112
}
115113
return &ValidationError{ErrMsg: res}

0 commit comments

Comments
 (0)