ソースを参照

Minor golint cleanups

Ask Bjørn Hansen 12 年 前
コミット
a1be596c3d
7 ファイル変更22 行追加19 行削除
  1. 1 0
      dayduration.go
  2. 3 2
      geodns.go
  3. 4 4
      monitor.go
  4. 1 1
      serve.go
  5. 3 3
      stathat.go
  6. 2 2
      util.go
  7. 8 7
      zones.go

+ 1 - 0
dayduration.go

@@ -26,6 +26,7 @@ func fmtInt(buf []byte, v uint64) int {
 	return w
 }
 
+// DayString returns string version of the time duration without too much precision.
 // Copied from time/time.go
 func (d DayDuration) DayString() string {
 	var buf [32]byte

+ 3 - 2
geodns.go

@@ -30,11 +30,12 @@ import (
 	"time"
 )
 
+// VERSION is the current version of GeoDNS
 var VERSION string = "2.3.0"
 var buildTime string
 var gitVersion string
 
-var serverId string
+var serverID string
 var serverIP string
 var serverGroups []string
 
@@ -75,7 +76,7 @@ func main() {
 
 	if len(*flagidentifier) > 0 {
 		ids := strings.Split(*flagidentifier, ",")
-		serverId = ids[0]
+		serverID = ids[0]
 		if len(ids) > 1 {
 			serverGroups = ids[1:]
 		}

+ 4 - 4
monitor.go

@@ -20,8 +20,8 @@ import (
 type statusStreamMsgStart struct {
 	Hostname string   `json:"h,omitemty"`
 	Version  string   `json:"v"`
-	Id       string   `json:"id"`
-	Ip       string   `json:"ip"`
+	ID       string   `json:"id"`
+	IP       string   `json:"ip"`
 	Uptime   int      `json:"up"`
 	Started  int      `json:"started"`
 	Groups   []string `json:"groups"`
@@ -135,8 +135,8 @@ func wsHandler(ws *websocket.Conn) {
 func initialStatus() string {
 	status := new(statusStreamMsgStart)
 	status.Version = VERSION
-	status.Id = serverId
-	status.Ip = serverIP
+	status.ID = serverID
+	status.IP = serverIP
 	if len(serverGroups) > 0 {
 		status.Groups = serverGroups
 	}

+ 1 - 1
serve.go

@@ -178,7 +178,7 @@ func statusRR(label string) []dns.RR {
 	h := dns.RR_Header{Ttl: 1, Class: dns.ClassINET, Rrtype: dns.TypeTXT}
 	h.Name = label
 
-	status := map[string]string{"v": VERSION, "id": serverId}
+	status := map[string]string{"v": VERSION, "id": serverID}
 
 	hostname, err := os.Hostname()
 	if err == nil {

+ 3 - 3
stathat.go

@@ -14,7 +14,7 @@ func (zs *Zones) statHatPoster() {
 		return
 	}
 
-	stathatGroups := append(serverGroups, "total", serverId)
+	stathatGroups := append(serverGroups, "total", serverID)
 	suffix := strings.Join(stathatGroups, ",")
 
 	lastCounts := map[string]int64{}
@@ -60,7 +60,7 @@ func (zs *Zones) statHatPoster() {
 func statHatPoster() {
 
 	lastQueryCount := qCounter.Count()
-	stathatGroups := append(serverGroups, "total", serverId)
+	stathatGroups := append(serverGroups, "total", serverID)
 	suffix := strings.Join(stathatGroups, ",")
 	// stathat.Verbose = true
 
@@ -79,7 +79,7 @@ func statHatPoster() {
 		lastQueryCount = current
 
 		stathat.PostEZCount("queries~"+suffix, Config.StatHat.ApiKey, int(newQueries))
-		stathat.PostEZValue("goroutines "+serverId, Config.StatHat.ApiKey, float64(runtime.NumGoroutine()))
+		stathat.PostEZValue("goroutines "+serverID, Config.StatHat.ApiKey, float64(runtime.NumGoroutine()))
 
 	}
 }

+ 2 - 2
util.go

@@ -40,8 +40,8 @@ func getInterfaces() []string {
 		}
 		uniq[host] = true
 
-		if len(serverId) == 0 {
-			serverId = ip
+		if len(serverID) == 0 {
+			serverID = ip
 		}
 		if len(serverIP) == 0 {
 			serverIP = ip

+ 8 - 7
zones.go

@@ -17,6 +17,7 @@ import (
 	"time"
 )
 
+// Zones maps domain names to zone data
 type Zones map[string]*Zone
 
 func zonesReader(dirName string, zones Zones) {
@@ -42,7 +43,7 @@ func zonesReadDir(dirName string, zones Zones) error {
 
 	seenZones := map[string]bool{}
 
-	var parse_err error
+	var parseErr error
 
 	for _, file := range dir {
 		fileName := file.Name()
@@ -70,7 +71,7 @@ func zonesReadDir(dirName string, zones Zones) error {
 				}
 				config.LastRead = file.ModTime()
 				zones[zoneName] = config
-				parse_err = err
+				parseErr = err
 				continue
 			}
 			config.LastRead = file.ModTime()
@@ -92,7 +93,7 @@ func zonesReadDir(dirName string, zones Zones) error {
 		delete(zones, zoneName)
 	}
 
-	return parse_err
+	return parseErr
 }
 
 func setupPgeodnsZone(zones Zones) {
@@ -251,11 +252,11 @@ func setupZoneData(data map[string]interface{}, Zone *Zone) {
 			case map[string]interface{}:
 				// Handle NS map syntax, map[ns2.example.net:<nil> ns1.example.net:<nil>]
 				tmp := make([]interface{}, 0)
-				for rdata_k, rdata_v := range rdata.(map[string]interface{}) {
-					if rdata_v == nil {
-						rdata_v = ""
+				for rdataK, rdataV := range rdata.(map[string]interface{}) {
+					if rdataV == nil {
+						rdataV = ""
 					}
-					tmp = append(tmp, []string{rdata_k, rdata_v.(string)})
+					tmp = append(tmp, []string{rdataK, rdataV.(string)})
 				}
 				records[rType] = tmp
 			case string: