diff --git a/.drone.yml b/.drone.yml index 3fab74a..55ac01b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,7 +8,7 @@ platform: steps: - name: deps - image: golang:1.19 + image: golang:1.20 commands: - make deps volumes: @@ -16,7 +16,7 @@ steps: path: /go - name: lint - image: golang:1.19 + image: golang:1.20 commands: - make lint volumes: @@ -24,7 +24,7 @@ steps: path: /go - name: test - image: golang:1.19 + image: golang:1.20 commands: - make test volumes: @@ -59,7 +59,7 @@ platform: steps: - name: build - image: techknowlogick/xgo:go-1.19.x + image: techknowlogick/xgo:go-1.20.x commands: - ln -s /drone/src /source - make release @@ -143,6 +143,6 @@ depends_on: --- kind: signature -hmac: e1c222b7a3d1b7aff9c4bea8205334456a620682a4cc4f6bb3959857f5029ebc +hmac: 25950586df979c42abe8651c8ee415ff6f8eab3261f4f5ac39c9c686fc43f843 ... diff --git a/.golangci.yml b/.golangci.yml index 7bb18ea..2faa799 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,25 +1,92 @@ linters: - enable: - - gosimple - - deadcode - - typecheck - - govet - - errcheck - - staticcheck - - unused - - structcheck - - varcheck - - dupl - - gofmt - - misspell - - gocritic - - bidichk - - ineffassign - - revive - - gofumpt - - depguard enable-all: false disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + - unused + - asasalint + - asciicheck + - bidichk + - bodyclose + - containedctx + - contextcheck + - decorder + - depguard + - dogsled + - dupl + - dupword + - durationcheck + - errchkjson + - errname + - errorlint + - execinquery + - exhaustive + - exportloopref + - forcetypeassert + - ginkgolinter + - gocheckcompilerdirectives + - gochecknoglobals + - gochecknoinits + - gocognit + - goconst + - gocritic + - gocyclo + - godot + - godox + - goerr113 + - gofmt + - gofumpt + - goheader + - goimports + - gomnd + - gomoddirectives + - gomodguard + - goprintffuncname + - gosec + - grouper + - importas + - interfacebloat + - ireturn + - lll + - loggercheck + - maintidx + - makezero + - misspell + - musttag + - nakedret + - nestif + - nilerr + - nilnil + - nlreturn + - noctx + - nolintlint + - nonamedreturns + - nosprintfhostport + - prealloc + - predeclared + - promlinter + - reassign + - revive + # - rowserrcheck + # - sqlclosecheck + # - structcheck + - stylecheck + - tagliatelle + - tenv + - testableexamples + - thelper + - tparallel + - unconvert + - unparam + - usestdlibvars + # - wastedassign + - whitespace + - wsl fast: false run: @@ -28,4 +95,4 @@ run: linters-settings: gofumpt: extra-rules: true - lang-version: "1.18" + lang-version: "1.20" diff --git a/Makefile b/Makefile index 16637b2..b87123e 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(G XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest GENERATE ?= -XGO_VERSION := go-1.19.x +XGO_VERSION := go-1.20.x XGO_TARGETS ?= linux/amd64,linux/arm-6,linux/arm-7,linux/arm64 TARGETOS ?= linux diff --git a/cmd/url-parser/main.go b/cmd/url-parser/main.go index ad738c4..ea85eec 100644 --- a/cmd/url-parser/main.go +++ b/cmd/url-parser/main.go @@ -9,6 +9,7 @@ import ( "github.com/urfave/cli/v2" ) +//nolint:gochecknoglobals var ( BuildVersion = "devel" BuildDate = "00000000" diff --git a/go.mod b/go.mod index 763c2ee..4d85234 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/thegeeklab/url-parser -go 1.19 +go 1.20 require ( github.com/sirupsen/logrus v1.9.0 diff --git a/internal/command/commands_test.go b/internal/command/commands_test.go index 5f5dd7b..7d20ed7 100644 --- a/internal/command/commands_test.go +++ b/internal/command/commands_test.go @@ -8,6 +8,7 @@ type TestParseData struct { } func TestParseURL(t *testing.T) { + //nolint:goconst urlString := "postgres://user:pass@host.com:5432/path/to?key=value&other=other%20value#some-fragment" tables := []TestParseData{ diff --git a/internal/command/fragment.go b/internal/command/fragment.go index 23c5e34..3a4f8f8 100644 --- a/internal/command/fragment.go +++ b/internal/command/fragment.go @@ -6,12 +6,13 @@ import ( "github.com/urfave/cli/v2" ) -// Fragment prints out the fragment part from the url +// Fragment prints out the fragment part from the url. func Fragment(ctx *cli.Context) error { parts := parseURL(ctx.String("url")) if len(parts.Scheme) > 0 { fmt.Println(parts.Fragment) } + return nil } diff --git a/internal/command/host.go b/internal/command/host.go index 2b987ab..285ed53 100644 --- a/internal/command/host.go +++ b/internal/command/host.go @@ -6,12 +6,13 @@ import ( "github.com/urfave/cli/v2" ) -// Host prints out the host part from the url +// Host prints out the host part from the url. func Host(ctx *cli.Context) error { parts := parseURL(ctx.String("url")) if len(parts.Scheme) > 0 { fmt.Println(parts.Hostname()) } + return nil } diff --git a/internal/command/password.go b/internal/command/password.go index 068cd45..6118134 100644 --- a/internal/command/password.go +++ b/internal/command/password.go @@ -6,7 +6,7 @@ import ( "github.com/urfave/cli/v2" ) -// Password prints out the password part from url +// Password prints out the password part from url. func Password(ctx *cli.Context) error { parts := parseURL(ctx.String("url")) diff --git a/internal/command/path.go b/internal/command/path.go index 3a39dec..f802536 100644 --- a/internal/command/path.go +++ b/internal/command/path.go @@ -7,7 +7,7 @@ import ( "github.com/urfave/cli/v2" ) -// PathFlags defines flags for path subcommand +// PathFlags defines flags for path subcommand. func PathFlags() []cli.Flag { return []cli.Flag{ &cli.IntFlag{ @@ -19,7 +19,7 @@ func PathFlags() []cli.Flag { } } -// Path prints out the path part from url +// Path prints out the path part from url. func Path(ctx *cli.Context) error { parts := parseURL(ctx.String("url")) i := ctx.Int("path-index") diff --git a/internal/command/port.go b/internal/command/port.go index 20cce99..ea1f38e 100644 --- a/internal/command/port.go +++ b/internal/command/port.go @@ -6,12 +6,13 @@ import ( "github.com/urfave/cli/v2" ) -// Port prints out the port from the url +// Port prints out the port from the url. func Port(ctx *cli.Context) error { parts := parseURL(ctx.String("url")) if len(parts.Scheme) > 0 { fmt.Println(parts.Port()) } + return nil } diff --git a/internal/command/query.go b/internal/command/query.go index c71ba58..bc5fe2e 100644 --- a/internal/command/query.go +++ b/internal/command/query.go @@ -6,7 +6,7 @@ import ( "github.com/urfave/cli/v2" ) -// QueryFlags defines flags for query subcommand +// QueryFlags defines flags for query subcommand. func QueryFlags() []cli.Flag { return []cli.Flag{ &cli.StringFlag{ @@ -17,7 +17,7 @@ func QueryFlags() []cli.Flag { } } -// Query prints out the query part from url +// Query prints out the query part from url. func Query(ctx *cli.Context) error { parts := parseURL(ctx.String("url")) f := ctx.String("query-field") diff --git a/internal/command/run.go b/internal/command/run.go index 802aa95..8dfea5e 100644 --- a/internal/command/run.go +++ b/internal/command/run.go @@ -6,12 +6,13 @@ import ( "github.com/urfave/cli/v2" ) -// Run default command and print out full url +// Run default command and print out full url. func Run(ctx *cli.Context) error { parts := parseURL(ctx.String("url")) if len(parts.String()) > 0 { fmt.Println(parts) } + return nil } diff --git a/internal/command/scheme.go b/internal/command/scheme.go index 856af3b..9bf0bab 100644 --- a/internal/command/scheme.go +++ b/internal/command/scheme.go @@ -6,12 +6,13 @@ import ( "github.com/urfave/cli/v2" ) -// Scheme prints out the scheme part from the url +// Scheme prints out the scheme part from the url. func Scheme(ctx *cli.Context) error { parts := parseURL(ctx.String("url")) if len(parts.Scheme) > 0 { fmt.Println(parts.Scheme) } + return nil } diff --git a/internal/command/user.go b/internal/command/user.go index e6d34b2..44153a8 100644 --- a/internal/command/user.go +++ b/internal/command/user.go @@ -6,7 +6,7 @@ import ( "github.com/urfave/cli/v2" ) -// User prints out the user part from url +// User prints out the user part from url. func User(ctx *cli.Context) error { parts := parseURL(ctx.String("url")) @@ -15,5 +15,6 @@ func User(ctx *cli.Context) error { fmt.Println(parts.User.Username()) } } + return nil }