Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
version: "2"
run:
timeout: 10m
allow-serial-runners: true
concurrency: 0
linters-settings:
goimports:
local-prefixes: github.com/theopenlane/httpsling
gofumpt:
extra-rules: true
gosec:
exclude-generated: true
revive:
ignore-generated-header: true
linters:
enable:
- bodyclose
- errcheck
- err113
- gocritic
- gocyclo
- err113
- gofmt
- goimports
- mnd
- gosimple
- govet
- gosec
- ineffassign
- misspell
- mnd
- noctx
- revive
- staticcheck
- stylecheck
- typecheck
- unused
- whitespace
- wsl
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- example_test.go
- httptestutil/*
- third_party$
- builtin$
- examples$
- _test.go$
- mocks.go
issues:
fix: true
exclude-use-default: true
exclude-dirs:
- httptestutil/*
exclude-files:
- example_test.go
formatters:
enable:
- gofmt
- goimports
settings:
gofumpt:
extra-rules: true
goimports:
local-prefixes:
- github.com/theopenlane/httpsling
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tasks:
go:lint:
desc: runs golangci-lint, the most annoying opinionated linter ever
cmds:
- golangci-lint run --config=.golangci.yaml --verbose --fast --fix
- golangci-lint run --config=.golangci.yaml --verbose --fix

go:fmt:
desc: format all go code
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ require (
github.com/felixge/httpsnoop v1.0.4
github.com/google/go-querystring v1.1.0
github.com/stretchr/testify v1.10.0
github.com/theopenlane/utils v0.4.3

github.com/theopenlane/utils v0.4.4
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/theopenlane/echox v0.2.1 h1:ZhVkimmWxpKITf67oM57SrLWeIdnV8+dNXlC+VzlRaQ=
github.com/theopenlane/echox v0.2.1/go.mod h1:4j/Hx0uoLk5gVzdA83Qqz7xBEmqpoEP+OnzVaw2p6/o=
github.com/theopenlane/utils v0.4.3 h1:0ZSqUzbbQt7lczLTIXlbYXOwLuKuQns//L2AHQOZdis=
github.com/theopenlane/utils v0.4.3/go.mod h1:UTzPMpvyCu35eGium50H7KroHU0+2mh1lMOYTb4Vi70=
github.com/theopenlane/utils v0.4.4 h1:4Xb2T+4bjMtf4OL73bWQ1a8zllTt43ryVflRzVaUgmU=
github.com/theopenlane/utils v0.4.4/go.mod h1:lNzPjqQoDM5565s5FRqkmBGO77twAkY3Hxgd38ESo6I=
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
Expand Down
10 changes: 5 additions & 5 deletions httpclient/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
// NoRedirects configures the client to no perform any redirects
func NoRedirects() Option {
return OptionFunc(func(client *http.Client) error {
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
client.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
}

Expand All @@ -20,10 +20,10 @@ func NoRedirects() Option {
}

// MaxRedirects configures the max number of redirects the client will perform before giving up
func MaxRedirects(max int) Option {
func MaxRedirects(m int) Option {
return OptionFunc(func(client *http.Client) error {
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
if len(via) >= max {
client.CheckRedirect = func(_ *http.Request, via []*http.Request) error {
if len(via) >= m {
return ErrMaxAttemptsExceeded
}

Expand Down Expand Up @@ -56,7 +56,7 @@ func ProxyURL(proxyURL string) Option {
return err
}

t.Proxy = func(request *http.Request) (*url.URL, error) {
t.Proxy = func(_ *http.Request) (*url.URL, error) {
return u, nil
}

Expand Down
4 changes: 2 additions & 2 deletions httptestutil/inspector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func TestInspectNilhandler(t *testing.T) {
require.NotNil(t, i.LastExchange())
}

func ExampleInspectorNextExchange() {
func ExampleInspector_NextExchange() {
i := NewInspector(0)

var h http.Handler = http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
Expand All @@ -232,7 +232,7 @@ func ExampleInspectorNextExchange() {
// <nil>
}

func ExampleInspectorLastExchange() {
func ExampleInspector_LastExchange() {
i := NewInspector(0)

var h http.Handler = http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion marshaling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func TestFormMarshalerMarshal(t *testing.T) {
}

func TestMarshalFuncApply(t *testing.T) {
var mf MarshalFunc = func(v interface{}) (bytes []byte, s string, e error) {
var mf MarshalFunc = func(_ interface{}) (bytes []byte, s string, e error) {
return nil, "red", nil
}

Expand Down
Loading