From 14e725954e9659ea51d703d2e7f67dc820fae171 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 26 Nov 2023 02:14:41 -0800 Subject: [PATCH] linter update (#31) --- .golangci.yml | 42 ++++++++++++++++++------------------------ datatypes.go | 2 +- main.go | 39 ++++++++++++++++++++------------------- 3 files changed, 39 insertions(+), 44 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d4702a2..40fbaad 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,39 +1,33 @@ -# Copyright 2021 Harshavardhana -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - linters-settings: - golint: - min-confidence: 0 + gofumpt: + simplify: true misspell: locale: US + staticcheck: + checks: ['all', '-ST1005', '-ST1000', '-SA4000', '-SA9004', '-SA1019', '-SA1008', '-U1000', '-ST1016'] + linters: disable-all: true enable: - - typecheck + - durationcheck + - gocritic + - gofumpt - goimports - - misspell + - gomodguard - govet - - revive - ineffassign - - deadcode + - misspell + - revive + - staticcheck + - tenv + - typecheck + - unconvert + - unused issues: exclude-use-default: false exclude: - - should have a package comment - - error strings should not be capitalized or end with punctuation or a newline -service: - golangci-lint-version: 1.20.0 # use the fixed version to not introduce new linters unexpectedly + - should have a package comment + - error strings should not be capitalized or end with punctuation or a newline diff --git a/datatypes.go b/datatypes.go index 6f58ce2..31396c4 100644 --- a/datatypes.go +++ b/datatypes.go @@ -42,7 +42,7 @@ func (o objectInfo) Mode() os.FileMode { if o.isDir { return os.ModeDir } - return os.FileMode(0644) + return os.FileMode(0o644) } func (o objectInfo) ModTime() time.Time { diff --git a/main.go b/main.go index db408ef..83b432c 100644 --- a/main.go +++ b/main.go @@ -27,11 +27,11 @@ import ( "strings" "time" + "github.com/IGLOU-EU/go-wildcard/v2" "github.com/caddyserver/certmagic" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" "github.com/minio/minio-go/v7/pkg/s3utils" - "github.com/IGLOU-EU/go-wildcard/v2" "github.com/rs/cors" ) @@ -121,19 +121,19 @@ func getObject(ctx context.Context, s3 *S3, name string) (*minio.Object, error) } var ( - endpoint string - accessKey string - accessKeyFile string - secretKey string - secretKeyFile string - address string - bucket string - bucketPath string - tlsCert string - tlsKey string - spaFile string - allowedCorsOrigin string - letsEncrypt bool + endpoint string + accessKey string + accessKeyFile string + secretKey string + secretKeyFile string + address string + bucket string + bucketPath string + tlsCert string + tlsKey string + spaFile string + allowedCorsOrigin string + letsEncrypt bool ) func init() { @@ -208,7 +208,7 @@ func main() { // - IAM profile based credentials. (performs an HTTP // call to a pre-defined endpoint, only valid inside // configured ec2 instances) - var defaultAWSCredProviders = []credentials.Provider{ + defaultAWSCredProviders := []credentials.Provider{ &credentials.EnvAWS{}, &credentials.FileAWSCredentials{}, &credentials.IAM{ @@ -287,14 +287,15 @@ func main() { AllowCredentials: true, } muxHandler := cors.New(opts).Handler(mux) - - if letsEncrypt { + + switch { + case letsEncrypt: log.Printf("Started listening on https://%s\n", address) certmagic.HTTPS([]string{address}, muxHandler) - } else if tlsCert != "" && tlsKey != "" { + case tlsCert != "" && tlsKey != "": log.Printf("Started listening on https://%s\n", address) log.Fatalln(http.ListenAndServeTLS(address, tlsCert, tlsKey, muxHandler)) - } else { + default: log.Printf("Started listening on http://%s\n", address) log.Fatalln(http.ListenAndServe(address, muxHandler)) }