forked from TimothyYe/godns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
51 lines (43 loc) · 879 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"errors"
"flag"
"fmt"
"log"
"runtime"
"strings"
)
func identifyPanic() string {
var name, file string
var line int
var pc [16]uintptr
n := runtime.Callers(3, pc[:])
for _, pc := range pc[:n] {
fn := runtime.FuncForPC(pc)
if fn == nil {
continue
}
file, line = fn.FileLine(pc)
name = fn.Name()
if !strings.HasPrefix(name, "runtime.") {
break
}
}
switch {
case name != "":
return fmt.Sprintf("%v:%v", name, line)
case file != "":
return fmt.Sprintf("%v:%v", file, line)
}
return fmt.Sprintf("pc:%x", pc)
}
func usage() {
log.Println("[command] -c=[config file path]")
flag.PrintDefaults()
}
func checkSettings(config *Settings) error {
if (config.Email == "" || config.Password == "") && config.LoginToken == "" {
return errors.New("Input email/password or login token cannot be empty!")
}
return nil
}