Skip to content

Commit

Permalink
linter update (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana committed Nov 26, 2023
1 parent b906d89 commit 14e7259
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 44 deletions.
42 changes: 18 additions & 24 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion datatypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
39 changes: 20 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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))
}
Expand Down

0 comments on commit 14e7259

Please sign in to comment.