Skip to content

Commit

Permalink
chore: add golangci-lint to CI (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar authored Aug 14, 2024
1 parent e6c038d commit 5b9dc92
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 8 deletions.
27 changes: 24 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
version: 2.1

jobs:
build:
working_directory: ~/repo
tests-go:
parameters:
go-image:
type: string
default: "cimg/go:1.22"
docker:
- image: cimg/go:1.22
- image: << parameters.go-image >>
steps:
- checkout
- restore_cache:
Expand Down Expand Up @@ -53,3 +57,20 @@ jobs:
./codecov
- store_artifacts:
path: /tmp/artifacts

lint:
docker:
- image: golangci/golangci-lint
steps:
- checkout
- run:
name: Lint go code
command: |
golangci-lint run -v
workflows:
version: 2
build:
jobs:
- tests-go
- lint
31 changes: 31 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused

output:
# The formats used to render issues.
# Default:
# formats:
# - format: colored-line-number
# path: stdout
formats:
- format: tab
path: stdout

# Make issues output unique by line.
# Default: true
uniq-by-line: false

# Sort results by the order defined in `sort-order`.
# Default: false
sort-results: true

# Show statistics per linter.
# Default: false
show-stats: true
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 0.10.0 [unreleased]

### CI

1. [#95](https://github.com/InfluxCommunity/influxdb3-go/pull/95): Add `golangci-lint` to CI

## 0.9.0 [2024-08-12]

### Features
Expand Down
8 changes: 4 additions & 4 deletions influxdb3/example_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ func ExampleClient_Query() {
defer client.Close()

// query
iterator, err := client.Query(context.Background(),
iterator, _ := client.Query(context.Background(),
"SELECT count(*) FROM weather WHERE time >= now() - interval '5 minutes'")

for iterator.Next() {
// process the result
}

// query with custom header
iterator, err = client.Query(context.Background(),
iterator, _ = client.Query(context.Background(),
"SELECT count(*) FROM stat WHERE time >= now() - interval '5 minutes'",
WithHeader("X-trace-ID", "#0122"))

Expand All @@ -60,7 +60,7 @@ func ExampleClient_QueryWithParameters() {
defer client.Close()

// query
iterator, err := client.QueryWithParameters(context.Background(),
iterator, _ := client.QueryWithParameters(context.Background(),
"SELECT count(*) FROM weather WHERE location = $location AND time >= now() - interval '5 minutes'",
QueryParameters{
"location": "sun-valley-1",
Expand All @@ -71,7 +71,7 @@ func ExampleClient_QueryWithParameters() {
}

// query with custom header
iterator, err = client.QueryWithParameters(context.Background(),
iterator, _ = client.QueryWithParameters(context.Background(),
"SELECT count(*) FROM weather WHERE location = $location AND time >= now() - interval '5 minutes'",
QueryParameters{
"location": "sun-valley-1",
Expand Down
2 changes: 1 addition & 1 deletion influxdb3/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestQueryWithDefaultHeaders(t *testing.T) {
defer c.Close()

c.setQueryClient(fc)
_, err = c.Query(context.Background(), "SELECT * FROM nothing")
_, _ = c.Query(context.Background(), "SELECT * FROM nothing")
assert.True(t, middleware.outgoingMDOk, "context contains outgoing MD")
assert.Equal(t, []string{userAgent}, middleware.outgoingMD["user-agent"], "default user agent header set")
assert.Equal(t, []string{"Bearer my-token"}, middleware.outgoingMD["authorization"], "authorization header set")
Expand Down

0 comments on commit 5b9dc92

Please sign in to comment.