瀏覽代碼

*: clean up unused vars, functions

With help from https://github.com/dominikh/go-unused.
IsNetTimeoutError seems useful, so moved to pkg/netutil.
Gyu-Ho Lee 9 年之前
父節點
當前提交
6e6d64fb9b
共有 10 個文件被更改,包括 11 次插入36 次删除
  1. 0 4
      client/auth_user.go
  2. 0 1
      client/keys_test.go
  3. 0 2
      etcdctl/ctlv3/ctl.go
  4. 1 1
      etcdmain/etcd.go
  5. 2 4
      etcdserver/api/v2http/http.go
  6. 5 0
      pkg/netutil/netutil.go
  7. 3 4
      proxy/director.go
  8. 0 2
      raft/raft.go
  9. 0 11
      rafthttp/stream.go
  10. 0 7
      storage/watcher_group.go

+ 0 - 4
client/auth_user.go

@@ -41,10 +41,6 @@ type UserRoles struct {
 	Roles []Role `json:"roles"`
 }
 
-type userName struct {
-	User string `json:"user"`
-}
-
 func v2AuthURL(ep url.URL, action string, name string) *url.URL {
 	if name != "" {
 		ep.Path = path.Join(ep.Path, defaultV2AuthPrefix, action, name)

+ 0 - 1
client/keys_test.go

@@ -1246,7 +1246,6 @@ func TestHTTPKeysAPIGetResponse(t *testing.T) {
 func TestHTTPKeysAPIDeleteAction(t *testing.T) {
 	tests := []struct {
 		key        string
-		value      string
 		opts       *DeleteOptions
 		wantAction httpAction
 	}{

+ 0 - 2
etcdctl/ctlv3/ctl.go

@@ -16,7 +16,6 @@
 package ctlv3
 
 import (
-	"text/tabwriter"
 	"time"
 
 	"github.com/coreos/etcd/etcdctl/ctlv3/command"
@@ -32,7 +31,6 @@ const (
 )
 
 var (
-	tabOut      *tabwriter.Writer
 	globalFlags = command.GlobalFlags{}
 )
 

+ 1 - 1
etcdmain/etcd.go

@@ -400,7 +400,7 @@ func startProxy(cfg *config) error {
 	}
 
 	cfg.dir = path.Join(cfg.dir, "proxy")
-	err = os.MkdirAll(cfg.dir, 0700)
+	err = os.MkdirAll(cfg.dir, privateDirMode)
 	if err != nil {
 		return err
 	}

+ 2 - 4
etcdserver/api/v2http/http.go

@@ -15,7 +15,6 @@
 package v2http
 
 import (
-	"errors"
 	"math"
 	"net/http"
 	"strings"
@@ -35,9 +34,8 @@ const (
 )
 
 var (
-	plog      = capnslog.NewPackageLogger("github.com/coreos/etcd/etcdserver/api", "v2http")
-	mlog      = logutil.NewMergeLogger(plog)
-	errClosed = errors.New("v2http: client closed connection")
+	plog = capnslog.NewPackageLogger("github.com/coreos/etcd/etcdserver/api", "v2http")
+	mlog = logutil.NewMergeLogger(plog)
 )
 
 // writeError logs and writes the given Error to the ResponseWriter

+ 5 - 0
pkg/netutil/netutil.go

@@ -116,3 +116,8 @@ func URLStringsEqual(a []string, b []string) bool {
 
 	return urlsEqual(urlsA, urlsB)
 }
+
+func IsNetworkTimeoutError(err error) bool {
+	nerr, ok := err.(net.Error)
+	return ok && nerr.Timeout()
+}

+ 3 - 4
proxy/director.go

@@ -67,10 +67,9 @@ func newDirector(urlsFunc GetProxyURLs, failureWait time.Duration, refreshInterv
 
 type director struct {
 	sync.Mutex
-	ep              []*endpoint
-	uf              GetProxyURLs
-	failureWait     time.Duration
-	refreshInterval time.Duration
+	ep          []*endpoint
+	uf          GetProxyURLs
+	failureWait time.Duration
 }
 
 func (d *director) refresh() {

+ 0 - 2
raft/raft.go

@@ -29,8 +29,6 @@ import (
 const None uint64 = 0
 const noLimit = math.MaxUint64
 
-var errNoLeader = errors.New("no leader")
-
 var ErrSnapshotTemporarilyUnavailable = errors.New("snapshot is temporarily unavailable")
 
 // Possible values for StateType.

+ 0 - 11
rafthttp/stream.go

@@ -374,12 +374,6 @@ func (cr *streamReader) stop() {
 	<-cr.done
 }
 
-func (cr *streamReader) isWorking() bool {
-	cr.mu.Lock()
-	defer cr.mu.Unlock()
-	return cr.closer != nil
-}
-
 func (cr *streamReader) dial(t streamType) (io.ReadCloser, error) {
 	u := cr.picker.pick()
 	uu := u
@@ -500,8 +494,3 @@ func checkStreamSupport(v *semver.Version, t streamType) bool {
 	}
 	return false
 }
-
-func isNetworkTimeoutError(err error) bool {
-	nerr, ok := err.(net.Error)
-	return ok && nerr.Timeout()
-}

+ 0 - 7
storage/watcher_group.go

@@ -143,13 +143,6 @@ func (w watcherSetByKey) delete(wa *watcher) bool {
 	return false
 }
 
-type interval struct {
-	begin string
-	end   string
-}
-
-type watcherSetByInterval map[interval]watcherSet
-
 // watcherGroup is a collection of watchers organized by their ranges
 type watcherGroup struct {
 	// keyWatchers has the watchers that watch on a single key