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
161 changes: 131 additions & 30 deletions closer/.golangci.yml

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions closer/closer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,28 @@ func TestCloser(t *testing.T) {
goleak.VerifyNone(t, goleak.IgnoreCurrent())

SetContext(context.WithValue(context.Background(), key, "testvalue"))

var ctxErr error
Add(func(ctx context.Context) error {
require.NoError(t, ctx.Err())
ctxErr = ctx.Err()
assert.Equal(t, "testvalue", ctx.Value(key))
return nil
})

wg := sync.WaitGroup{}
wg.Add(1)
var err error
go func() {
defer wg.Done()
<-Done()
require.NoError(t, Err())
wg.Done()
err = Err()
}()

CloseAll()
wg.Wait()

require.NoError(t, ctxErr)
require.NoError(t, err)
})

t.Run("with context cancel", func(t *testing.T) {
Expand All @@ -66,17 +72,19 @@ func TestCloser(t *testing.T) {

wg := sync.WaitGroup{}
wg.Add(1)
var err error
go func() {
defer wg.Done()
<-c.Done()
err := c.Err()
require.ErrorContains(t, err, "test error #1")
require.ErrorContains(t, err, "test error #2")
wg.Done()
err = c.Err()
}()

cancel()
wg.Wait()

require.ErrorContains(t, err, "test error #1")
require.ErrorContains(t, err, "test error #2")

assert.Equal(t, uint32(2), cnt.Load())
})

Expand Down
160 changes: 131 additions & 29 deletions ctxkey/.golangci.yml

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions deferred/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ linters:
- asasalint # Check for pass []any as any in variadic func(…any).
- asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name.
- bidichk # Checks for dangerous unicode character sequences.
- bodyclose # Checks whether HTTP response body is closed successfully.
- canonicalheader # Canonicalheader checks whether net/http.Header uses canonical header.
- containedctx # Containedctx is a linter that detects struct contained context.Context field.
- contextcheck # Check whether the function uses a non-inherited context.
- copyloopvar # Copyloopvar is a linter detects places where loop variables are copied.
Expand All @@ -33,7 +31,6 @@ linters:
- durationcheck # Check for two durations multiplied together.
- embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields.
- errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases.
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and reports occurrences where the check for the returned error can be omitted.
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
- errorlint # Errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions.
Expand All @@ -56,10 +53,8 @@ linters:
- mirror # Reports wrong mirror patterns of bytes/strings usage.
- mnd # An analyzer to detect magic numbers.
- modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features.
- musttag # Enforce field tags in (un)marshaled structs.
- nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero).
- nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
- noctx # Finds sending http request without context.Context.
- nolintlint # Reports ill-formed or insufficient nolint directives.
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative.
Expand Down Expand Up @@ -125,10 +120,6 @@ linters:
- encoding/json.Marshal
- encoding/json.MarshalIndent

errchkjson:
check-error-free-encoding: true
report-no-exported: true

gocognit:
min-complexity: 10

Expand Down
41 changes: 34 additions & 7 deletions dispatcher/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ linters:
- asasalint # Check for pass []any as any in variadic func(…any).
- asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name.
- bidichk # Checks for dangerous unicode character sequences.
- bodyclose # Checks whether HTTP response body is closed successfully.
- canonicalheader # Canonicalheader checks whether net/http.Header uses canonical header.
- containedctx # Containedctx is a linter that detects struct contained context.Context field.
- contextcheck # Check whether the function uses a non-inherited context.
- copyloopvar # Copyloopvar is a linter detects places where loop variables are copied.
- depguard # Go linter that checks if package imports are in a list of acceptable packages.
- dupword # Checks for duplicate words in the source code.
- durationcheck # Check for two durations multiplied together.
- embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields.
Expand All @@ -53,10 +52,9 @@ linters:
- makezero # Finds slice declarations with non-zero initial length.
- mirror # Reports wrong mirror patterns of bytes/strings usage.
- mnd # An analyzer to detect magic numbers.
- musttag # Enforce field tags in (un)marshaled structs.
- modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features.
- nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero).
- nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
- noctx # Finds sending http request without context.Context.
- nolintlint # Reports ill-formed or insufficient nolint directives.
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative.
Expand All @@ -67,6 +65,7 @@ linters:
- testifylint # Checks usage of github.com/stretchr/testify.
- testpackage # Linter that makes you use a separate _test package.
- thelper # Thelper detects tests helpers which do not start with the t.Helper() method.
- tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes.
- unconvert # Remove unnecessary type conversions.
- unused # Checks Go code for unused constants, variables, functions and types.
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library.
Expand All @@ -80,8 +79,36 @@ linters:
linters: [ errcheck ]
- path: (.+)_test\.go
linters: [ gocognit, goconst, mnd ]
- text: 'assigned to ctx'
linters: [ wastedassign ]
- text: 'ctx is never used'
linters: [ staticcheck ]

paths:
- \\.git$
- assets$
- bench(mark)?s?$
- bin$
- build$
- configs?$
- deploy(ment)?s?$
- docs$
- githooks$
- scripts$

generated: strict

settings:
depguard:
rules:
main:
list-mode: lax
deny:
- pkg: 'math/rand$'
desc: 'use math/rand/v2'
- pkg: 'github.com/pkg/errors'
desc: 'Should be replaced by standard lib errors package'

dupword:
comments-only: true

Expand Down Expand Up @@ -216,12 +243,12 @@ linters:
- stringXbytes # Detects redundant conversions between string and []byte.
- zeroByteRepeat # Detects bytes.Repeat with 0 value.

gomoddirectives:
replace-local: true

goheader:
template-path: ../.github/goheader.tmpl

gomoddirectives:
replace-local: true

gosec:
excludes:
# _ instead of err checks
Expand Down
15 changes: 6 additions & 9 deletions protomap/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ linters:
- asasalint # Check for pass []any as any in variadic func(…any).
- asciicheck # Checks that all code identifiers does not have non-ASCII symbols in the name.
- bidichk # Checks for dangerous unicode character sequences.
- bodyclose # Checks whether HTTP response body is closed successfully.
- canonicalheader # Canonicalheader checks whether net/http.Header uses canonical header.
- containedctx # Containedctx is a linter that detects struct contained context.Context field.
- contextcheck # Check whether the function uses a non-inherited context.
- copyloopvar # Copyloopvar is a linter detects places where loop variables are copied.
Expand All @@ -33,7 +31,6 @@ linters:
- durationcheck # Check for two durations multiplied together.
- embeddedstructfieldcheck # Embedded types should be at the top of the field list of a struct, and there must be an empty line separating embedded fields from regular fields.
- errcheck # Errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases.
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and reports occurrences where the check for the returned error can be omitted.
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
- errorlint # Errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions.
Expand All @@ -56,14 +53,13 @@ linters:
- mirror # Reports wrong mirror patterns of bytes/strings usage.
- mnd # An analyzer to detect magic numbers.
- modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features.
- musttag # Enforce field tags in (un)marshaled structs.
- nakedret # Checks that functions with naked returns are not longer than a maximum size (can be zero).
- nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
- noctx # Finds sending http request without context.Context.
- nolintlint # Reports ill-formed or insufficient nolint directives.
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative.
- prealloc # Finds slice declarations that could potentially be pre-allocated.
- protogetter # Reports direct reads from proto message fields when getters should be used.
- reassign # Checks that package variables are not reassigned.
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go.
- staticcheck # It's a set of rules from staticcheck.
Expand Down Expand Up @@ -125,10 +121,6 @@ linters:
- encoding/json.Marshal
- encoding/json.MarshalIndent

errchkjson:
check-error-free-encoding: true
report-no-exported: true

gocognit:
min-complexity: 10

Expand Down Expand Up @@ -290,6 +282,11 @@ linters:
prealloc:
range-loops: true

protogetter:
skip-files:
- '*/vendor/*'
skip-any-generated: true

reassign:
patterns:
- '.*'
Expand Down
2 changes: 1 addition & 1 deletion protomap/protomap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,6 @@ func TestProtomap_Unmarshal(t *testing.T) {
require.NoError(t, err)

first.Value = "changed"
assert.Equal(t, "value", second.Value)
assert.Equal(t, "value", second.GetValue())
})
}
Loading
Loading