From ced892fd1ad10708a68942628ee809db4f0ddbb1 Mon Sep 17 00:00:00 2001 From: Kane York Date: Fri, 15 Sep 2017 16:30:11 -0700 Subject: [PATCH] Fix more warnings --- socketserver/server/handlecore.go | 5 +++-- socketserver/server/stats.go | 2 +- socketserver/server/usercount.go | 15 ++++----------- socketserver/server/utils.go | 14 -------------- 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/socketserver/server/handlecore.go b/socketserver/server/handlecore.go index 905dde04..d23afb58 100644 --- a/socketserver/server/handlecore.go +++ b/socketserver/server/handlecore.go @@ -505,7 +505,7 @@ func SendMessage(conn *websocket.Conn, msg ClientMessage) { } // UnmarshalClientMessage unpacks websocket TextMessage into a ClientMessage provided in the `v` parameter. -func UnmarshalClientMessage(data []byte, payloadType int, v interface{}) (err error) { +func UnmarshalClientMessage(data []byte, _ int, v interface{}) (err error) { var spaceIdx int out := v.(*ClientMessage) @@ -550,7 +550,8 @@ func (cm *ClientMessage) parseOrigArguments() error { return nil } -func MarshalClientMessage(clientMessage interface{}) (payloadType int, data []byte, err error) { +// returns payloadType, data, err +func MarshalClientMessage(clientMessage interface{}) (int, []byte, error) { var msg ClientMessage var ok bool msg, ok = clientMessage.(ClientMessage) diff --git a/socketserver/server/stats.go b/socketserver/server/stats.go index 8455fa8f..6eec5e93 100644 --- a/socketserver/server/stats.go +++ b/socketserver/server/stats.go @@ -209,7 +209,7 @@ func updateSysMem() { } // HTTPShowStatistics handles the /stats endpoint. It writes out the Statistics object as indented JSON. -func HTTPShowStatistics(w http.ResponseWriter, r *http.Request) { +func HTTPShowStatistics(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") updateStatsIfNeeded() diff --git a/socketserver/server/usercount.go b/socketserver/server/usercount.go index 1b9cbcbb..25fae97a 100644 --- a/socketserver/server/usercount.go +++ b/socketserver/server/usercount.go @@ -46,11 +46,6 @@ var uniqueCtrWritingToken chan usageToken var CounterLocation *time.Location = time.FixedZone("UTC-5", int((time.Hour*-5)/time.Second)) -func TruncateToMidnight(at time.Time) time.Time { - year, month, day := at.Date() - return time.Date(year, month, day, 0, 0, 0, 0, CounterLocation) -} - // GetCounterPeriod calculates the start and end timestamps for the HLL measurement period that includes the 'at' timestamp. func GetCounterPeriod(at time.Time) (start time.Time, end time.Time) { year, month, day := at.Date() @@ -132,7 +127,7 @@ func HTTPShowHLL(w http.ResponseWriter, r *http.Request) { hllFileServer.ServeHTTP(w, r) } -func HTTPWriteHLL(w http.ResponseWriter, r *http.Request) { +func HTTPWriteHLL(w http.ResponseWriter, _ *http.Request) { writeHLL() w.WriteHeader(200) w.Write([]byte("ok")) @@ -150,9 +145,7 @@ func loadUniqueUsers() { now := time.Now().In(CounterLocation) uniqueCounter.Start, uniqueCounter.End = GetCounterPeriod(now) err = loadHLL(now, &uniqueCounter) - isIgnorableError := err != nil && (false || - (os.IsNotExist(err)) || - (err == io.EOF)) + isIgnorableError := err != nil && (os.IsNotExist(err) || err == io.EOF) if isIgnorableError { // file didn't finish writing @@ -227,10 +220,10 @@ func rolloverCounters_do() { // Attempt to rescue the data into the log var buf bytes.Buffer - bytes, err := uniqueCounter.Counter.GobEncode() + by, err := uniqueCounter.Counter.GobEncode() if err == nil { enc := base64.NewEncoder(base64.StdEncoding, &buf) - enc.Write(bytes) + enc.Write(by) enc.Close() log.Print("data for ", GetHLLFilename(uniqueCounter.Start), ":", buf.String()) } diff --git a/socketserver/server/utils.go b/socketserver/server/utils.go index 6657dd02..a91feda4 100644 --- a/socketserver/server/utils.go +++ b/socketserver/server/utils.go @@ -161,17 +161,3 @@ func RemoveFromSliceCl(ary *[]*ClientInfo, val *ClientInfo) bool { *ary = slice return true } - -func AddToSliceB(ary *[]bunchSubscriber, client *ClientInfo, mid int) bool { - newSub := bunchSubscriber{Client: client, MessageID: mid} - slice := *ary - for _, v := range slice { - if v == newSub { - return false - } - } - - slice = append(slice, newSub) - *ary = slice - return true -}