From 628d8a0b0565b9d6fc5e8538858119e015da3d10 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Mon, 25 Feb 2019 16:07:53 +0000 Subject: [PATCH] go fmt --- src/handlers.go | 13 ++++++------- src/instance.go | 8 ++++---- src/mothd.go | 4 +--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/handlers.go b/src/handlers.go index 950d45a..d4674d7 100644 --- a/src/handlers.go +++ b/src/handlers.go @@ -14,17 +14,17 @@ import ( // https://github.com/omniti-labs/jsend type JSend struct { - Status string `json:"status"` + Status string `json:"status"` Data struct { Short string `json:"short"` Description string `json:"description"` - } `json:"data"` + } `json:"data"` } const ( JSendSuccess = "success" - JSendFail = "fail" - JSendError = "error" + JSendFail = "fail" + JSendError = "error" ) func respond(w http.ResponseWriter, req *http.Request, status string, short string, format string, a ...interface{}) { @@ -255,7 +255,7 @@ func (ctx *Instance) staticHandler(w http.ResponseWriter, req *http.Request) { } type FurtiveResponseWriter struct { - w http.ResponseWriter + w http.ResponseWriter statusCode *int } @@ -276,7 +276,7 @@ func (w FurtiveResponseWriter) Header() http.Header { // This gives Instances the signature of http.Handler func (ctx *Instance) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { w := FurtiveResponseWriter{ - w: wOrig, + w: wOrig, statusCode: new(int), } ctx.mux.ServeHTTP(w, r) @@ -297,4 +297,3 @@ func (ctx *Instance) BindHandlers() { ctx.mux.HandleFunc(ctx.Base+"/puzzles.json", ctx.puzzlesHandler) ctx.mux.HandleFunc(ctx.Base+"/points.json", ctx.pointsHandler) } - diff --git a/src/instance.go b/src/instance.go index bd89e5d..6f5dd95 100644 --- a/src/instance.go +++ b/src/instance.go @@ -6,12 +6,12 @@ import ( "io" "io/ioutil" "log" + "math/rand" "net/http" "os" "path" "strings" "time" - "math/rand" ) type Instance struct { @@ -23,7 +23,7 @@ type Instance struct { update chan bool jPuzzleList []byte jPointsLog []byte - mux *http.ServeMux + mux *http.ServeMux } func NewInstance(base, mothballDir, stateDir, resourcesDir string) (*Instance, error) { @@ -44,7 +44,7 @@ func NewInstance(base, mothballDir, stateDir, resourcesDir string) (*Instance, e if _, err := os.Stat(stateDir); err != nil { return nil, err } - + ctx.BindHandlers() ctx.MaybeInitialize() @@ -56,7 +56,7 @@ const distinguishableChars = "234678abcdefhijkmnpqrtwxyz=" func mktoken() string { a := make([]byte, 8) - for i := range(a) { + for i := range a { char := rand.Intn(len(distinguishableChars)) a[i] = distinguishableChars[char] } diff --git a/src/mothd.go b/src/mothd.go index 46b7d42..ef08832 100644 --- a/src/mothd.go +++ b/src/mothd.go @@ -3,19 +3,17 @@ package main import ( "github.com/namsral/flag" "log" + "math/rand" "mime" "net/http" "time" - "math/rand" ) - func setup() error { rand.Seed(time.Now().UnixNano()) return nil } - func main() { base := flag.String( "base",