# HG changeset patch # User Sascha L. Teichmann # Date 1565083407 -7200 # Node ID 34623265eac15687428b8d2e662d979a63f2421a # Parent 49012340336c4ef74141491c057e83a6eb3b9d4a Made 'golint' happy (again) with the controllers package. diff -r 49012340336c -r 34623265eac1 pkg/controllers/srimports.go --- a/pkg/controllers/srimports.go Tue Aug 06 11:13:28 2019 +0200 +++ b/pkg/controllers/srimports.go Tue Aug 06 11:23:27 2019 +0200 @@ -214,7 +214,7 @@ var once sync.Once closeOnce := func() { zr.Close() } - var isZIP bool = false + var isZIP bool if zr, err = zip.OpenReader(srFile); err != nil { messages = append(messages, fmt.Sprintf("%v - "+ "Trying TXT file mode.", err)) diff -r 49012340336c -r 34623265eac1 pkg/controllers/uploadedimports.go --- a/pkg/controllers/uploadedimports.go Tue Aug 06 11:13:28 2019 +0200 +++ b/pkg/controllers/uploadedimports.go Tue Aug 06 11:23:27 2019 +0200 @@ -29,7 +29,8 @@ const maxUploadSize = 25 * 1024 * 1024 -type BadUploadParameterError string +// badUploadParameterError is a local type to find bad request parameters. +type badUploadParameterError string func importWaterwayProfiles() http.HandlerFunc { return uploadedImport( @@ -38,12 +39,12 @@ func(req *http.Request, dir string) (imports.Job, error) { url := req.FormValue("url") if url == "" { - return nil, BadUploadParameterError("missing 'url' parameter") + return nil, badUploadParameterError("missing 'url' parameter") } featureType := req.FormValue("feature-type") if featureType == "" { - return nil, BadUploadParameterError("missing 'feature-type' parameter") + return nil, badUploadParameterError("missing 'feature-type' parameter") } sortBy := req.FormValue("sort-by") @@ -52,7 +53,7 @@ if p := req.FormValue("precision"); p != "" { v, err := strconv.ParseFloat(p, 64) if err != nil { - return nil, BadUploadParameterError( + return nil, badUploadParameterError( fmt.Sprintf("Invalid 'precision' parameter: %v", err)) } precision = &v @@ -81,7 +82,7 @@ func(req *http.Request, dir string) (imports.Job, error) { originator := req.FormValue("originator") if originator == "" { - return nil, BadUploadParameterError("missing 'originator' parameter") + return nil, badUploadParameterError("missing 'originator' parameter") } return &imports.ApprovedGaugeMeasurements{ @@ -102,7 +103,7 @@ if t := req.FormValue("tolerance"); t != "" { v, err := strconv.ParseFloat(t, 64) if err != nil { - return nil, BadUploadParameterError( + return nil, badUploadParameterError( fmt.Sprintf("Invalid 'tolerance' parameter: %v", err)) } tolerance = v @@ -133,7 +134,7 @@ ) } -func (bup BadUploadParameterError) Error() string { +func (bup badUploadParameterError) Error() string { return string(bup) } @@ -160,7 +161,7 @@ if err2 := os.RemoveAll(dir); err2 != nil { log.Printf("warn: %v\n", err2) } - if err2, ok := err.(BadUploadParameterError); ok { + if err2, ok := err.(badUploadParameterError); ok { http.Error(rw, string(err2), http.StatusBadRequest) return }