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)
This commit is contained in:
Shane Howearth 2019-09-18 16:23:30 +10:00 committed by Cecylia Bocovich
parent b26c7a7a73
commit 8bbdb3b51a
6 changed files with 11 additions and 11 deletions

View file

@ -44,13 +44,13 @@ func (p *Peers) Collect() (Snowflake, error) {
cnt := p.Count() cnt := p.Count()
s := fmt.Sprintf("Currently at [%d/%d]", cnt, p.capacity) s := fmt.Sprintf("Currently at [%d/%d]", cnt, p.capacity)
if 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) return nil, errors.New(s)
} }
log.Println("WebRTC: Collecting a new Snowflake.", s) log.Println("WebRTC: Collecting a new Snowflake.", s)
// Engage the Snowflake Catching interface, which must be available. // Engage the Snowflake Catching interface, which must be available.
if nil == p.Tongue { 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. // BUG: some broker conflict here.
connection, err := p.Tongue.Catch() connection, err := p.Tongue.Catch()

View file

@ -144,7 +144,7 @@ func NewWebRTCDialer(
// Initialize a WebRTC Connection by signaling through the broker. // Initialize a WebRTC Connection by signaling through the broker.
func (w WebRTCDialer) Catch() (Snowflake, error) { func (w WebRTCDialer) Catch() (Snowflake, error) {
if nil == w.BrokerChannel { 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: [#3] Fetch ICE server information from Broker.
// TODO: [#18] Consider TURN servers here too. // TODO: [#18] Consider TURN servers here too.

View file

@ -309,7 +309,7 @@ func (c *WebRTCPeer) exchangeSDP() error {
} }
// Keep trying the same offer until a valid answer arrives. // Keep trying the same offer until a valid answer arrives.
var ok bool var ok bool
var answer *webrtc.SessionDescription = nil var answer *webrtc.SessionDescription
for nil == answer { for nil == answer {
go c.sendOfferToBroker() go c.sendOfferToBroker()
answer, ok = <-c.answerChannel // Blocks... answer, ok = <-c.answerChannel // Blocks...

View file

@ -14,7 +14,7 @@ import (
"syscall" "syscall"
"time" "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" sf "git.torproject.org/pluggable-transports/snowflake.git/client/lib"
"git.torproject.org/pluggable-transports/snowflake.git/common/safelog" "git.torproject.org/pluggable-transports/snowflake.git/common/safelog"
"github.com/pion/webrtc" "github.com/pion/webrtc"
@ -102,7 +102,7 @@ func main() {
// deadlock because the buffer is full. // deadlock because the buffer is full.
// https://bugs.torproject.org/26360 // https://bugs.torproject.org/26360
// https://bugs.torproject.org/25600#comment:14 // https://bugs.torproject.org/25600#comment:14
var logOutput io.Writer = ioutil.Discard var logOutput = ioutil.Discard
if *logFilename != "" { if *logFilename != "" {
if *logToStateDir { if *logToStateDir {
stateDir, err := pt.MakeStateDir() stateDir, err := pt.MakeStateDir()
@ -184,7 +184,7 @@ func main() {
} }
pt.CmethodsDone() pt.CmethodsDone()
var numHandlers int = 0 var numHandlers int
var sig os.Signal var sig os.Signal
sigChan := make(chan os.Signal, 1) sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGTERM) signal.Notify(sigChan, syscall.SIGTERM)

View file

@ -19,7 +19,7 @@ import (
"syscall" "syscall"
"time" "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/snowflake.git/common/safelog"
"git.torproject.org/pluggable-transports/websocket.git/websocket" "git.torproject.org/pluggable-transports/websocket.git/websocket"
"golang.org/x/crypto/acme/autocert" "golang.org/x/crypto/acme/autocert"
@ -390,7 +390,7 @@ func main() {
} }
pt.SmethodsDone() pt.SmethodsDone()
var numHandlers int = 0 var numHandlers int
var sig os.Signal var sig os.Signal
sigChan := make(chan os.Signal, 1) sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGTERM) signal.Notify(sigChan, syscall.SIGTERM)

View file

@ -27,9 +27,9 @@ func statsThread() {
select { select {
case v := <-statsChannel: case v := <-statsChannel:
if v { if v {
numClientIP += 1 numClientIP++
} }
numConnections += 1 numConnections++
case <-deadline: case <-deadline:
now := time.Now() now := time.Now()
log.Printf("in the past %.f s, %d/%d connections had client_ip", log.Printf("in the past %.f s, %d/%d connections had client_ip",