Browse Source

chore(*): gofmt everything

Brandon Philips 12 years ago
parent
commit
ea8a353545

+ 7 - 7
etcd.go

@@ -118,18 +118,18 @@ func main() {
 
 	// Calculate all of our timeouts
 	heartbeatTimeout := time.Duration(config.Peer.HeartbeatTimeout) * time.Millisecond
-	electionTimeout :=  time.Duration(config.Peer.ElectionTimeout) * time.Millisecond
+	electionTimeout := time.Duration(config.Peer.ElectionTimeout) * time.Millisecond
 	dialTimeout := (3 * heartbeatTimeout) + electionTimeout
 	responseHeaderTimeout := (3 * heartbeatTimeout) + electionTimeout
 
 	// Create peer server.
 	psConfig := server.PeerServerConfig{
-		Name:             info.Name,
-		Scheme:           peerTLSConfig.Scheme,
-		URL:              info.RaftURL,
-		SnapshotCount:    config.SnapshotCount,
-		MaxClusterSize:   config.MaxClusterSize,
-		RetryTimes:       config.MaxRetryAttempts,
+		Name:           info.Name,
+		Scheme:         peerTLSConfig.Scheme,
+		URL:            info.RaftURL,
+		SnapshotCount:  config.SnapshotCount,
+		MaxClusterSize: config.MaxClusterSize,
+		RetryTimes:     config.MaxRetryAttempts,
 	}
 	ps := server.NewPeerServer(psConfig, registry, store, &mb, followersStats, serverStats)
 

+ 0 - 1
metrics/standard.go

@@ -19,7 +19,6 @@ const (
 	GraphitePublishInterval = time.Duration(2) * time.Second
 )
 
-
 type standardBucket struct {
 	sync.Mutex
 	name     string

+ 5 - 5
mod/dashboard/resources/bindata-file.go

@@ -1,11 +1,11 @@
 package resources
 
 func File(name string) ([]byte, bool) {
-       data, ok := go_bindata[name]
+	data, ok := go_bindata[name]
 
-       if ok == false {
-               return nil, false
-       }
+	if ok == false {
+		return nil, false
+	}
 
-       return data(), true
+	return data(), true
 }

+ 1 - 1
mod/dashboard/resources/bindata-toc.go

@@ -4,4 +4,4 @@ package resources
 // After startup of the program, all generated data files will
 // put themselves in this map. The key is the full filename, as
 // supplied to go-bindata.
-var go_bindata = make(map[string]func() []byte)
+var go_bindata = make(map[string]func() []byte)

+ 0 - 1
mod/dashboard/resources/browser.html.go

@@ -33,7 +33,6 @@ func browser_html() []byte {
 	return buf.Bytes()
 }
 
-
 func init() {
 	go_bindata["/browser.html"] = browser_html
 }

+ 0 - 1
mod/dashboard/resources/index.html.go

@@ -33,7 +33,6 @@ func index_html() []byte {
 	return buf.Bytes()
 }
 
-
 func init() {
 	go_bindata["/index.html"] = index_html
 }

+ 0 - 1
mod/dashboard/resources/scripts-browser-modules.js.go

@@ -33,7 +33,6 @@ func scripts_browser_modules_js() []byte {
 	return buf.Bytes()
 }
 
-
 func init() {
 	go_bindata["/scripts/browser-modules.js"] = scripts_browser_modules_js
 }

+ 0 - 1
mod/dashboard/resources/scripts-browser-scripts.js.go

@@ -33,7 +33,6 @@ func scripts_browser_scripts_js() []byte {
 	return buf.Bytes()
 }
 
-
 func init() {
 	go_bindata["/scripts/browser-scripts.js"] = scripts_browser_scripts_js
 }

+ 0 - 1
mod/dashboard/resources/scripts-stats-modules.js.go

@@ -33,7 +33,6 @@ func scripts_stats_modules_js() []byte {
 	return buf.Bytes()
 }
 
-
 func init() {
 	go_bindata["/scripts/stats-modules.js"] = scripts_stats_modules_js
 }

+ 0 - 1
mod/dashboard/resources/scripts-stats-scripts.js.go

@@ -33,7 +33,6 @@ func scripts_stats_scripts_js() []byte {
 	return buf.Bytes()
 }
 
-
 func init() {
 	go_bindata["/scripts/stats-scripts.js"] = scripts_stats_scripts_js
 }

+ 0 - 1
mod/dashboard/resources/stats.html.go

@@ -33,7 +33,6 @@ func stats_html() []byte {
 	return buf.Bytes()
 }
 
-
 func init() {
 	go_bindata["/stats.html"] = stats_html
 }

+ 0 - 1
mod/dashboard/resources/styles-main.css.go

@@ -33,7 +33,6 @@ func styles_main_css() []byte {
 	return buf.Bytes()
 }
 
-
 func init() {
 	go_bindata["/styles/main.css"] = styles_main_css
 }

+ 0 - 1
mod/dashboard/resources/views-browser.html.go

@@ -33,7 +33,6 @@ func views_browser_html() []byte {
 	return buf.Bytes()
 }
 
-
 func init() {
 	go_bindata["/views/browser.html"] = views_browser_html
 }

+ 0 - 1
mod/dashboard/resources/views-stats.html.go

@@ -33,7 +33,6 @@ func views_stats_html() []byte {
 	return buf.Bytes()
 }
 
-
 func init() {
 	go_bindata["/views/stats.html"] = views_stats_html
 }

+ 1 - 1
mod/leader/v2/delete_handler.go

@@ -6,8 +6,8 @@ import (
 	"net/http"
 	"net/url"
 
-	"github.com/gorilla/mux"
 	etcdErr "github.com/coreos/etcd/error"
+	"github.com/gorilla/mux"
 )
 
 // deleteHandler remove a given leader.

+ 7 - 7
mod/leader/v2/handler.go

@@ -3,8 +3,8 @@ package v2
 import (
 	"net/http"
 
-	"github.com/gorilla/mux"
 	etcdErr "github.com/coreos/etcd/error"
+	"github.com/gorilla/mux"
 )
 
 // prefix is appended to the lock's prefix since the leader mod uses the lock mod.
@@ -13,19 +13,19 @@ const prefix = "/_mod/leader"
 // handler manages the leader HTTP request.
 type handler struct {
 	*mux.Router
-	client *http.Client
+	client    *http.Client
 	transport *http.Transport
-	addr string
+	addr      string
 }
 
 // NewHandler creates an HTTP handler that can be registered on a router.
-func NewHandler(addr string) (http.Handler) {
+func NewHandler(addr string) http.Handler {
 	transport := &http.Transport{DisableKeepAlives: false}
 	h := &handler{
-		Router: mux.NewRouter(),
-		client: &http.Client{Transport: transport},
+		Router:    mux.NewRouter(),
+		client:    &http.Client{Transport: transport},
 		transport: transport,
-		addr: addr,
+		addr:      addr,
 	}
 	h.StrictSlash(false)
 	h.handleFunc("/{key:.*}", h.getHandler).Methods("GET")

+ 1 - 1
mod/leader/v2/set_handler.go

@@ -6,8 +6,8 @@ import (
 	"net/http"
 	"net/url"
 
-	"github.com/gorilla/mux"
 	etcdErr "github.com/coreos/etcd/error"
+	"github.com/gorilla/mux"
 )
 
 // setHandler attempts to set the current leader.

+ 0 - 2
mod/leader/v2/tests/mod_leader_test.go

@@ -66,8 +66,6 @@ func TestModLeaderRenew(t *testing.T) {
 	})
 }
 
-
-
 func testSetLeader(s *server.Server, key string, name string, ttl int) (string, int, error) {
 	resp, err := tests.PutForm(fmt.Sprintf("%s/mod/v2/leader/%s?name=%s&ttl=%d", s.URL(), key, name, ttl), nil)
 	ret := tests.ReadBody(resp)

+ 7 - 7
mod/lock/v2/acquire_handler.go

@@ -8,9 +8,9 @@ import (
 	"strconv"
 	"time"
 
-	"github.com/gorilla/mux"
-	"github.com/coreos/go-etcd/etcd"
 	etcdErr "github.com/coreos/etcd/error"
+	"github.com/coreos/go-etcd/etcd"
+	"github.com/gorilla/mux"
 )
 
 // acquireHandler attempts to acquire a lock on the given key.
@@ -75,7 +75,7 @@ func (h *handler) acquireHandler(w http.ResponseWriter, req *http.Request) error
 }
 
 // createNode creates a new lock node and watches it until it is acquired or acquisition fails.
-func (h *handler) createNode(keypath string, value string, ttl int, closeChan <- chan bool, stopChan chan bool) (int, error) {
+func (h *handler) createNode(keypath string, value string, ttl int, closeChan <-chan bool, stopChan chan bool) (int, error) {
 	// Default the value to "-" if it is blank.
 	if len(value) == 0 {
 		value = "-"
@@ -133,7 +133,7 @@ func (h *handler) findExistingNode(keypath string, value string) (*etcd.Node, in
 func (h *handler) ttlKeepAlive(k string, value string, ttl int, stopChan chan bool) {
 	for {
 		select {
-		case <-time.After(time.Duration(ttl / 2) * time.Second):
+		case <-time.After(time.Duration(ttl/2) * time.Second):
 			h.client.Update(k, value, uint64(ttl))
 		case <-stopChan:
 			return
@@ -143,14 +143,14 @@ func (h *handler) ttlKeepAlive(k string, value string, ttl int, stopChan chan bo
 
 // watch continuously waits for a given lock index to be acquired or until lock fails.
 // Returns a boolean indicating success.
-func (h *handler) watch(keypath string, index int, closeChan <- chan bool) error {
+func (h *handler) watch(keypath string, index int, closeChan <-chan bool) error {
 	// Wrap close chan so we can pass it to Client.Watch().
 	stopWatchChan := make(chan bool)
 	go func() {
 		select {
-		case <- closeChan:
+		case <-closeChan:
 			stopWatchChan <- true
-		case <- stopWatchChan:
+		case <-stopWatchChan:
 		}
 	}()
 	defer close(stopWatchChan)

+ 1 - 1
mod/lock/v2/get_index_handler.go

@@ -4,8 +4,8 @@ import (
 	"net/http"
 	"path"
 
-	"github.com/gorilla/mux"
 	etcdErr "github.com/coreos/etcd/error"
+	"github.com/gorilla/mux"
 )
 
 // getIndexHandler retrieves the current lock index.

+ 3 - 3
mod/lock/v2/handler.go

@@ -3,9 +3,9 @@ package v2
 import (
 	"net/http"
 
-	"github.com/gorilla/mux"
-	"github.com/coreos/go-etcd/etcd"
 	etcdErr "github.com/coreos/etcd/error"
+	"github.com/coreos/go-etcd/etcd"
+	"github.com/gorilla/mux"
 )
 
 const prefix = "/_etcd/mod/lock"
@@ -17,7 +17,7 @@ type handler struct {
 }
 
 // NewHandler creates an HTTP handler that can be registered on a router.
-func NewHandler(addr string) (http.Handler) {
+func NewHandler(addr string) http.Handler {
 	h := &handler{
 		Router: mux.NewRouter(),
 		client: etcd.NewClient([]string{addr}),

+ 2 - 3
mod/lock/v2/release_handler.go

@@ -1,11 +1,11 @@
 package v2
 
 import (
-	"path"
 	"net/http"
+	"path"
 
-	"github.com/gorilla/mux"
 	etcdErr "github.com/coreos/etcd/error"
+	"github.com/gorilla/mux"
 )
 
 // releaseLockHandler deletes the lock.
@@ -45,4 +45,3 @@ func (h *handler) releaseLockHandler(w http.ResponseWriter, req *http.Request) e
 
 	return nil
 }
-

+ 2 - 2
mod/lock/v2/renew_handler.go

@@ -1,12 +1,12 @@
 package v2
 
 import (
-	"path"
 	"net/http"
+	"path"
 	"strconv"
 
-	"github.com/gorilla/mux"
 	etcdErr "github.com/coreos/etcd/error"
+	"github.com/gorilla/mux"
 )
 
 // renewLockHandler attempts to update the TTL on an existing lock.

+ 4 - 6
mod/lock/v2/tests/mod_lock_test.go

@@ -52,7 +52,7 @@ func TestModLockBlockUntilAcquire(t *testing.T) {
 			assert.Equal(t, body, "2")
 			c <- true
 		}()
-		<- c
+		<-c
 
 		// Acquire lock #2.
 		waiting := true
@@ -64,7 +64,7 @@ func TestModLockBlockUntilAcquire(t *testing.T) {
 			assert.Equal(t, body, "4")
 			waiting = false
 		}()
-		<- c
+		<-c
 
 		time.Sleep(1 * time.Second)
 
@@ -114,7 +114,7 @@ func TestModLockExpireAndRelease(t *testing.T) {
 			assert.Equal(t, body, "2")
 			c <- true
 		}()
-		<- c
+		<-c
 
 		// Acquire lock #2.
 		go func() {
@@ -124,7 +124,7 @@ func TestModLockExpireAndRelease(t *testing.T) {
 			assert.Equal(t, status, 200)
 			assert.Equal(t, body, "4")
 		}()
-		<- c
+		<-c
 
 		time.Sleep(1 * time.Second)
 
@@ -215,8 +215,6 @@ func TestModLockAcquireAndReleaseByValue(t *testing.T) {
 	})
 }
 
-
-
 func testAcquireLock(s *server.Server, key string, value string, ttl int) (string, int, error) {
 	resp, err := tests.PostForm(fmt.Sprintf("%s/mod/v2/lock/%s?value=%s&ttl=%d", s.URL(), key, value, ttl), nil)
 	ret := tests.ReadBody(resp)

+ 2 - 2
mod/mod.go

@@ -6,15 +6,15 @@ import (
 	"path"
 
 	"github.com/coreos/etcd/mod/dashboard"
-	lock2 "github.com/coreos/etcd/mod/lock/v2"
 	leader2 "github.com/coreos/etcd/mod/leader/v2"
+	lock2 "github.com/coreos/etcd/mod/lock/v2"
 	"github.com/gorilla/mux"
 )
 
 var ServeMux *http.Handler
 
 func addSlash(w http.ResponseWriter, req *http.Request) {
-	http.Redirect(w, req, path.Join("mod", req.URL.Path) + "/", 302)
+	http.Redirect(w, req, path.Join("mod", req.URL.Path)+"/", 302)
 	return
 }
 

+ 10 - 10
server/peer_server.go

@@ -25,12 +25,12 @@ const retryInterval = 10
 const ThresholdMonitorTimeout = 5 * time.Second
 
 type PeerServerConfig struct {
-	Name             string
-	Scheme           string
-	URL              string
-	SnapshotCount    int
-	MaxClusterSize   int
-	RetryTimes       int
+	Name           string
+	Scheme         string
+	URL            string
+	SnapshotCount  int
+	MaxClusterSize int
+	RetryTimes     int
 }
 
 type PeerServer struct {
@@ -65,11 +65,11 @@ type snapshotConf struct {
 
 func NewPeerServer(psConfig PeerServerConfig, registry *Registry, store store.Store, mb *metrics.Bucket, followersStats *raftFollowersStats, serverStats *raftServerStats) *PeerServer {
 	s := &PeerServer{
-		Config: psConfig,
-		registry: registry,
-		store:    store,
+		Config:         psConfig,
+		registry:       registry,
+		store:          store,
 		followersStats: followersStats,
-		serverStats: serverStats,
+		serverStats:    serverStats,
 
 		timeoutThresholdChan: make(chan interface{}, 1),
 

+ 1 - 0
server/release_version.go

@@ -1,2 +1,3 @@
 package server
+
 const ReleaseVersion = "v0.2.1-pre"

+ 3 - 3
server/server.go

@@ -29,9 +29,9 @@ type Server struct {
 	peerServer *PeerServer
 	registry   *Registry
 	store      store.Store
-	metrics        *metrics.Bucket
+	metrics    *metrics.Bucket
 
-	trace          bool
+	trace bool
 }
 
 // Creates a new Server.
@@ -42,7 +42,7 @@ func New(name, url string, peerServer *PeerServer, registry *Registry, store sto
 		store:      store,
 		registry:   registry,
 		peerServer: peerServer,
-		metrics:     mb,
+		metrics:    mb,
 	}
 
 	return s

+ 1 - 1
server/v2/tests/post_handler_test.go

@@ -2,8 +2,8 @@ package v2
 
 import (
 	"fmt"
-	"testing"
 	"net/http"
+	"testing"
 
 	"github.com/coreos/etcd/server"
 	"github.com/coreos/etcd/tests"

+ 2 - 2
tests/functional/kill_random_test.go

@@ -51,7 +51,7 @@ func TestKillRandom(t *testing.T) {
 
 		}
 
-		for num, _ := range toKill {
+		for num := range toKill {
 			err := etcds[num].Kill()
 			if err != nil {
 				panic(err)
@@ -63,7 +63,7 @@ func TestKillRandom(t *testing.T) {
 
 		<-leaderChan
 
-		for num, _ := range toKill {
+		for num := range toKill {
 			etcds[num], err = os.StartProcess(EtcdBinPath, argGroup[num], procAttr)
 		}
 

+ 1 - 1
tests/functional/util.go

@@ -100,7 +100,7 @@ func CreateCluster(size int, procAttr *os.ProcAttr, ssl bool) ([][]string, []*os
 
 	etcds := make([]*os.Process, size)
 
-	for i, _ := range etcds {
+	for i := range etcds {
 		var err error
 		etcds[i], err = os.StartProcess(EtcdBinPath, append(argGroup[i], "-f"), procAttr)
 		if err != nil {

+ 5 - 5
tests/server_utils.go

@@ -33,10 +33,10 @@ func RunServer(f func(*server.Server)) {
 	followersStats := server.NewRaftFollowersStats(testName)
 
 	psConfig := server.PeerServerConfig{
-		Name: testName,
-		URL: "http://"+testRaftURL,
-		Scheme: "http",
-		SnapshotCount: testSnapshotCount,
+		Name:           testName,
+		URL:            "http://" + testRaftURL,
+		Scheme:         "http",
+		SnapshotCount:  testSnapshotCount,
 		MaxClusterSize: 9,
 	}
 	ps := server.NewPeerServer(psConfig, registry, store, nil, followersStats, serverStats)
@@ -48,7 +48,7 @@ func RunServer(f func(*server.Server)) {
 	// Create Raft transporter and server
 	dialTimeout := (3 * testHeartbeatTimeout) + testElectionTimeout
 	responseHeaderTimeout := (3 * testHeartbeatTimeout) + testElectionTimeout
-	raftTransporter := server.NewTransporter(followersStats, serverStats, registry,	testHeartbeatTimeout, dialTimeout, responseHeaderTimeout)
+	raftTransporter := server.NewTransporter(followersStats, serverStats, registry, testHeartbeatTimeout, dialTimeout, responseHeaderTimeout)
 	raftServer, err := raft.NewServer(testName, path, raftTransporter, store, ps, "")
 	if err != nil {
 		panic(err)

+ 1 - 2
third_party.go

@@ -292,8 +292,7 @@ func bump(pkg, version string) {
 // validPkg uses go list to decide if the given path is a valid go package.
 // This is used by the bumpAll walk to bump all of the existing packages.
 func validPkg(pkg string) bool {
-	env := append(os.Environ(),
-	)
+	env := append(os.Environ())
 	cmd := exec.Command("go", "list", pkg)
 	cmd.Env = env