Skip to content

Commit

Permalink
chore: add golangci lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Apr 11, 2024
1 parent a5d92b2 commit 34df5dd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ jobs:
cache-dependency-path: ./go.sum
id: go

- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.55.2
# Optional: working directory, useful for monorepos
working-directory: .
# Optional: golangci-lint command line arguments.
args: --verbose
# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
skip-cache: true

- name: Build
run: go build ./...

Expand Down
27 changes: 27 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
linters:
enable:
- errorlint
- gci
- gocritic
- gofumpt
- misspell
- nonamedreturns

linters-settings:
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors.
# See the https://github.com/polyfloyd/go-errorlint for caveats.
errorf: true
# Permit more than 1 %w verb, valid per Go 1.20 (Requires errorf:true)
errorf-multi: true
# Check for plain type assertions and type switches.
asserts: true
# Check for plain error comparisons.
comparison: true
gci:
sections:
- standard
- default
- prefix(github.com/testcontainers)
run:
timeout: 5m
10 changes: 6 additions & 4 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func ExampleSelfSigned() {
certsDir := tmp + "/certs"
defer os.RemoveAll(certsDir)

if err := os.MkdirAll(certsDir, 0755); err != nil {
log.Fatal(err)
if err := os.MkdirAll(certsDir, 0o755); err != nil {
log.Fatal(err) // nolint: gocritic
}

// Generate a certificate for localhost and save it to disk.
Expand Down Expand Up @@ -51,7 +51,10 @@ func ExampleSelfSigned() {

server.Handler = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.Write([]byte("TLS works!\n"))
_, err := w.Write([]byte("TLS works!\n"))
if err != nil {
log.Printf("Failed to write response: %v", err)
}
})

go func() {
Expand Down Expand Up @@ -90,5 +93,4 @@ func ExampleSelfSigned() {

// Output:
// TLS works!

}

0 comments on commit 34df5dd

Please sign in to comment.