From e0bde61c5c1beed879820701a932141c52c72712 Mon Sep 17 00:00:00 2001 From: Timothy Date: Fri, 27 Oct 2017 11:57:54 +0800 Subject: [PATCH] fix golint warnings --- handler/dnspod_handler.go | 1 + settings.go | 8 ++++---- utils.go | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/handler/dnspod_handler.go b/handler/dnspod_handler.go index 987bc43..4501cb2 100644 --- a/handler/dnspod_handler.go +++ b/handler/dnspod_handler.go @@ -22,6 +22,7 @@ type DNSPodHandler struct { Configuration *godns.Settings } +// SetConfiguration pass dns settings and store it to handler instance func (handler *DNSPodHandler) SetConfiguration(conf *godns.Settings) { handler.Configuration = conf } diff --git a/settings.go b/settings.go index 196055e..e648381 100644 --- a/settings.go +++ b/settings.go @@ -6,13 +6,13 @@ import ( "io/ioutil" ) -//Domain struct +// Domain struct type Domain struct { DomainName string `json:"domain_name"` SubDomains []string `json:"sub_domains"` } -//Settings struct +// Settings struct type Settings struct { Provider string `json:"provider"` Email string `json:"email"` @@ -26,9 +26,9 @@ type Settings struct { Socks5Proxy string `json:"socks5_proxy"` } -//LoadSettings -- Load settings from config file +// LoadSettings -- Load settings from config file func LoadSettings(configPath string, settings *Settings) error { - //LoadSettings from config file + // LoadSettings from config file file, err := ioutil.ReadFile(configPath) if err != nil { fmt.Println("Error occurs while reading config file, please make sure config file exists!") diff --git a/utils.go b/utils.go index 9aeea8f..434f96e 100644 --- a/utils.go +++ b/utils.go @@ -24,6 +24,7 @@ const ( HE = "HE" ) +// GetCurrentIP gets public IP from internet func GetCurrentIP(configuration *Settings) (string, error) { client := &http.Client{} @@ -55,6 +56,7 @@ func GetCurrentIP(configuration *Settings) (string, error) { return string(body), nil } +// IdentifyPanic identifies panic and output the detailed panic infomation func IdentifyPanic() string { var name, file string var line int @@ -83,11 +85,13 @@ func IdentifyPanic() string { return fmt.Sprintf("pc:%x", pc) } +// Usage prints the usage of GoDNS func Usage() { log.Println("[command] -c=[config file path]") flag.PrintDefaults() } +// CheckSettings check the format of settings func CheckSettings(config *Settings) error { if config.Provider == DNSPOD { if (config.Email == "" || config.Password == "") && config.LoginToken == "" {