aboutsummaryrefslogtreecommitdiff
path: root/middleware
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-11-07 07:43:38 +0000
committerGravatar GitHub <noreply@github.com> 2016-11-07 07:43:38 +0000
commitfc85754849f564b43c2ce43e7e8b9804a80a035c (patch)
treee3ca315dd67cd94289bc6ffd80fe023bf981a3d1 /middleware
parentd3dae8d77f8be0800dc261c7982c53a34c9fb744 (diff)
downloadcoredns-fc85754849f564b43c2ce43e7e8b9804a80a035c.tar.gz
coredns-fc85754849f564b43c2ce43e7e8b9804a80a035c.tar.zst
coredns-fc85754849f564b43c2ce43e7e8b9804a80a035c.zip
Golint (#386)
Lint and vet the curret code add docs about adding a git post-commit hook that performs these actions after each commit.
Diffstat (limited to 'middleware')
-rw-r--r--middleware/file/tree/print.go24
-rw-r--r--middleware/kubernetes/controller.go12
2 files changed, 20 insertions, 16 deletions
diff --git a/middleware/file/tree/print.go b/middleware/file/tree/print.go
index f098e56c7..d95e7e189 100644
--- a/middleware/file/tree/print.go
+++ b/middleware/file/tree/print.go
@@ -11,20 +11,20 @@ func (t *Tree) Print() {
}
func (n *Node) print() {
- q := NewQueue()
- q.Push(n)
+ q := newQueue()
+ q.push(n)
nodesInCurrentLevel := 1
nodesInNextLevel := 0
- for !q.Empty() {
- do := q.Pop()
+ for !q.empty() {
+ do := q.pop()
nodesInCurrentLevel--
if do != nil {
fmt.Print(do.Elem.Name(), " ")
- q.Push(do.Left)
- q.Push(do.Right)
+ q.push(do.Left)
+ q.push(do.Right)
nodesInNextLevel += 2
}
if nodesInCurrentLevel == 0 {
@@ -38,21 +38,25 @@ func (n *Node) print() {
type queue []*Node
-func NewQueue() queue {
+// newQueue returns a new queue.
+func newQueue() queue {
q := queue([]*Node{})
return q
}
-func (q *queue) Push(n *Node) {
+// push pushes n to the end of the queue.
+func (q *queue) push(n *Node) {
*q = append(*q, n)
}
-func (q *queue) Pop() *Node {
+// pop pops the first element off the queue.
+func (q *queue) pop() *Node {
n := (*q)[0]
*q = (*q)[1:]
return n
}
-func (q *queue) Empty() bool {
+// empty returns true when the queue containes zero nodes.
+func (q *queue) empty() bool {
return len(*q) == 0
}
diff --git a/middleware/kubernetes/controller.go b/middleware/kubernetes/controller.go
index 4110dc6bb..cd2628604 100644
--- a/middleware/kubernetes/controller.go
+++ b/middleware/kubernetes/controller.go
@@ -83,12 +83,12 @@ func serviceListFunc(c *kubernetes.Clientset, ns string, s *labels.Selector) fun
if s != nil {
opts.LabelSelector = *s
}
- list_v1, err := c.Core().Services(ns).List(opts)
+ listV1, err := c.Core().Services(ns).List(opts)
if err != nil {
return nil, err
}
- var list_api api.ServiceList
- err = v1.Convert_v1_ServiceList_To_api_ServiceList(list_v1, &list_api, nil)
+ var listAPI api.ServiceList
+ err = v1.Convert_v1_ServiceList_To_api_ServiceList(listV1, &listAPI, nil)
if err != nil {
return nil, err
}
@@ -110,12 +110,12 @@ func namespaceListFunc(c *kubernetes.Clientset, s *labels.Selector) func(api.Lis
if s != nil {
opts.LabelSelector = *s
}
- list_v1, err := c.Core().Namespaces().List(opts)
+ listV1, err := c.Core().Namespaces().List(opts)
if err != nil {
return nil, err
}
- var list_api api.NamespaceList
- err = v1.Convert_v1_NamespaceList_To_api_NamespaceList(list_v1, &list_api, nil)
+ var listAPI api.NamespaceList
+ err = v1.Convert_v1_NamespaceList_To_api_NamespaceList(listV1, &listAPI, nil)
if err != nil {
return nil, err
}