[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Bring code into line with Golangci-lint linters



commit 8bbdb3b51aacc15a36cb44853460945b0955511c
Author: Shane Howearth <Shane.h.1@xxxxxxxxx>
Date:   Wed Sep 18 16:23:30 2019 +1000

    Bring code into line with Golangci-lint linters
    
    - Error strings are no longer capitalized nor end with punctuation
    - Alias import
    - Remove extraneous initilisation code (No need to provide zero value
            for variables, because the compiler does that anyway)
---
 client/lib/peers.go      | 4 ++--
 client/lib/rendezvous.go | 2 +-
 client/lib/webrtc.go     | 2 +-
 client/snowflake.go      | 6 +++---
 server/server.go         | 4 ++--
 server/stats.go          | 4 ++--
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/client/lib/peers.go b/client/lib/peers.go
index 21411ed..5493bfd 100644
--- a/client/lib/peers.go
+++ b/client/lib/peers.go
@@ -44,13 +44,13 @@ func (p *Peers) Collect() (Snowflake, error) {
 	cnt := p.Count()
 	s := fmt.Sprintf("Currently at [%d/%d]", cnt, p.capacity)
 	if cnt >= p.capacity {
-		s := fmt.Sprintf("At capacity [%d/%d]", cnt, p.capacity)
+		s = fmt.Sprintf("At capacity [%d/%d]", cnt, p.capacity)
 		return nil, errors.New(s)
 	}
 	log.Println("WebRTC: Collecting a new Snowflake.", s)
 	// Engage the Snowflake Catching interface, which must be available.
 	if nil == p.Tongue {
-		return nil, errors.New("Missing Tongue to catch Snowflakes with.")
+		return nil, errors.New("missing Tongue to catch Snowflakes with")
 	}
 	// BUG: some broker conflict here.
 	connection, err := p.Tongue.Catch()
diff --git a/client/lib/rendezvous.go b/client/lib/rendezvous.go
index b13b841..0c7225b 100644
--- a/client/lib/rendezvous.go
+++ b/client/lib/rendezvous.go
@@ -144,7 +144,7 @@ func NewWebRTCDialer(
 // Initialize a WebRTC Connection by signaling through the broker.
 func (w WebRTCDialer) Catch() (Snowflake, error) {
 	if nil == w.BrokerChannel {
-		return nil, errors.New("Cannot Dial WebRTC without a BrokerChannel.")
+		return nil, errors.New("cannot Dial WebRTC without a BrokerChannel")
 	}
 	// TODO: [#3] Fetch ICE server information from Broker.
 	// TODO: [#18] Consider TURN servers here too.
diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go
index 84494d5..9d1ba37 100644
--- a/client/lib/webrtc.go
+++ b/client/lib/webrtc.go
@@ -309,7 +309,7 @@ func (c *WebRTCPeer) exchangeSDP() error {
 	}
 	// Keep trying the same offer until a valid answer arrives.
 	var ok bool
-	var answer *webrtc.SessionDescription = nil
+	var answer *webrtc.SessionDescription
 	for nil == answer {
 		go c.sendOfferToBroker()
 		answer, ok = <-c.answerChannel // Blocks...
diff --git a/client/snowflake.go b/client/snowflake.go
index 883a665..18b704f 100644
--- a/client/snowflake.go
+++ b/client/snowflake.go
@@ -14,7 +14,7 @@ import (
 	"syscall"
 	"time"
 
-	"git.torproject.org/pluggable-transports/goptlib.git"
+	pt "git.torproject.org/pluggable-transports/goptlib.git"
 	sf "git.torproject.org/pluggable-transports/snowflake.git/client/lib"
 	"git.torproject.org/pluggable-transports/snowflake.git/common/safelog"
 	"github.com/pion/webrtc"
@@ -102,7 +102,7 @@ func main() {
 	// deadlock because the buffer is full.
 	// https://bugs.torproject.org/26360
 	// https://bugs.torproject.org/25600#comment:14
-	var logOutput io.Writer = ioutil.Discard
+	var logOutput = ioutil.Discard
 	if *logFilename != "" {
 		if *logToStateDir {
 			stateDir, err := pt.MakeStateDir()
@@ -184,7 +184,7 @@ func main() {
 	}
 	pt.CmethodsDone()
 
-	var numHandlers int = 0
+	var numHandlers int
 	var sig os.Signal
 	sigChan := make(chan os.Signal, 1)
 	signal.Notify(sigChan, syscall.SIGTERM)
diff --git a/server/server.go b/server/server.go
index 3100fc9..5d15df6 100644
--- a/server/server.go
+++ b/server/server.go
@@ -19,7 +19,7 @@ import (
 	"syscall"
 	"time"
 
-	"git.torproject.org/pluggable-transports/goptlib.git"
+	pt "git.torproject.org/pluggable-transports/goptlib.git"
 	"git.torproject.org/pluggable-transports/snowflake.git/common/safelog"
 	"git.torproject.org/pluggable-transports/websocket.git/websocket"
 	"golang.org/x/crypto/acme/autocert"
@@ -390,7 +390,7 @@ func main() {
 	}
 	pt.SmethodsDone()
 
-	var numHandlers int = 0
+	var numHandlers int
 	var sig os.Signal
 	sigChan := make(chan os.Signal, 1)
 	signal.Notify(sigChan, syscall.SIGTERM)
diff --git a/server/stats.go b/server/stats.go
index 204e587..47aefc6 100644
--- a/server/stats.go
+++ b/server/stats.go
@@ -27,9 +27,9 @@ func statsThread() {
 		select {
 		case v := <-statsChannel:
 			if v {
-				numClientIP += 1
+				numClientIP++
 			}
-			numConnections += 1
+			numConnections++
 		case <-deadline:
 			now := time.Now()
 			log.Printf("in the past %.f s, %d/%d connections had client_ip",



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits