summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-04-18 16:32:18 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-04-18 16:32:18 -0400
commitbab083546c3370016f911efc575259109293addc (patch)
treec482ed235133a8ad97725d428dc149fb008a44f3
parent3b6279ddf21ca58b8cf9469c04a249d69ea449cb (diff)
golint
-rw-r--r--main.go27
-rw-r--r--tinc.go11
2 files changed, 18 insertions, 20 deletions
diff --git a/main.go b/main.go
index 9c86758..2378b8c 100644
--- a/main.go
+++ b/main.go
@@ -17,9 +17,8 @@ import (
func fmtAddress(node, port string) string {
if isIPv6(node) {
return fmt.Sprintf("[%s]:%s", node, port)
- } else {
- return fmt.Sprintf("%s:%s", node, port)
}
+ return fmt.Sprintf("%s:%s", node, port)
}
func isIPv6(node string) bool {
@@ -72,29 +71,29 @@ func doAddress(host, network, address string) Point {
var _wg sync.WaitGroup
_wg.Add(2)
- var result_name string
- var result_version string
- var result_error error
+ var resultName string
+ var resultVersion string
+ var resultError error
go func() {
defer _wg.Done()
- result_name, result_version, result_error = hello(addr)
+ resultName, resultVersion, resultError = hello(addr)
}()
- var result_ping float64
+ var resultPing float64
go func() {
defer _wg.Done()
- result_ping = Ping(addr.IP)
+ resultPing = Ping(addr.IP)
}()
_wg.Wait()
result := map[string]interface{}{}
- if result_error == nil {
- result["name"] = result_name
- result["version"] = result_version
+ if resultError == nil {
+ result["name"] = resultName
+ result["version"] = resultVersion
} else {
- result["error"] = result_error
+ result["error"] = resultError
}
- if result_ping >= 0 {
- result["ping"] = result_ping
+ if resultPing >= 0 {
+ result["ping"] = resultPing
}
return NewPoint("public", tags, result)
diff --git a/tinc.go b/tinc.go
index d06a6d2..62c9100 100644
--- a/tinc.go
+++ b/tinc.go
@@ -15,11 +15,10 @@ type Error struct {
}
func (e Error) Error() string {
- if e.Line > 0 {
- return fmt.Sprintf("%v:%v: %v", e.File, e.Line, e.Err)
- } else {
+ if e.Line < 1 {
return fmt.Sprintf("%v: %v", e.File, e.Err)
}
+ return fmt.Sprintf("%v:%v: %v", e.File, e.Line, e.Err)
}
func parseConfigLine(line string) (key, val string) {
@@ -43,7 +42,7 @@ func parseConfigLine(line string) (key, val string) {
// a map of settings. Since Tinc setting names are case-insensitive,
// the keys in the map are all lower-case.
func ReadConfigFile(fname string) (map[string][]string, error) {
- config_tree := make(map[string][]string)
+ cfg := make(map[string][]string)
fp, err := os.Open(fname)
if err != nil {
@@ -83,14 +82,14 @@ func ReadConfigFile(fname string) (map[string][]string, error) {
return nil, Error{File: fname, Line: lineno, Err: err}
}
variable = strings.ToLower(variable)
- config_tree[variable] = append(config_tree[variable], value)
+ cfg[variable] = append(cfg[variable], value)
}
err = buffer.Err()
if err != nil {
return nil, Error{File: fname, Err: err}
}
- return config_tree, nil
+ return cfg, nil
}
// GetAddresses inspects a tinc host-confing settings object and