fix: resolve golangci-lint failures and .gitignore scope issue
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- cmd/server/main.go: acknowledge w.Write return value (errcheck) - internal/store/mongo.go: use errors.Is for ErrNoDocuments (errorlint) - .golangci.yml: add linter config scoped to relevant linters - .gitignore: scope /server to root only (was blocking cmd/server/ directory) Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
2e07374681
commit
675f765cc0
4
.gitignore
vendored
4
.gitignore
vendored
@ -2,5 +2,5 @@
|
|||||||
cast-ghl-provider
|
cast-ghl-provider
|
||||||
/tmp/
|
/tmp/
|
||||||
|
|
||||||
# compiled binary (root)
|
# compiled binary (root-level only, not cmd/server/ directory)
|
||||||
server
|
/server
|
||||||
|
|||||||
25
.golangci.yml
Normal file
25
.golangci.yml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- errcheck
|
||||||
|
- govet
|
||||||
|
- staticcheck
|
||||||
|
- gosimple
|
||||||
|
- ineffassign
|
||||||
|
- unused
|
||||||
|
- errorlint
|
||||||
|
- gocritic
|
||||||
|
- revive
|
||||||
|
|
||||||
|
linters-settings:
|
||||||
|
revive:
|
||||||
|
rules:
|
||||||
|
- name: exported
|
||||||
|
disabled: true
|
||||||
|
|
||||||
|
issues:
|
||||||
|
exclude-rules:
|
||||||
|
# Test files can use dot-imports and assertion helpers freely
|
||||||
|
- path: _test\.go
|
||||||
|
linters:
|
||||||
|
- errcheck
|
||||||
|
- gocritic
|
||||||
@ -85,5 +85,5 @@ func main() {
|
|||||||
func healthCheck(w http.ResponseWriter, r *http.Request) {
|
func healthCheck(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
w.Write([]byte(`{"status":"ok","service":"cast-ghl-provider"}`))
|
_, _ = w.Write([]byte(`{"status":"ok","service":"cast-ghl-provider"}`))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package store
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/v2/bson"
|
"go.mongodb.org/mongo-driver/v2/bson"
|
||||||
@ -61,7 +62,7 @@ func (s *Store) GetToken(ctx context.Context, locationID string) (*TokenRecord,
|
|||||||
filter := bson.D{{Key: "location_id", Value: locationID}}
|
filter := bson.D{{Key: "location_id", Value: locationID}}
|
||||||
var record TokenRecord
|
var record TokenRecord
|
||||||
err := s.collection.FindOne(ctx, filter).Decode(&record)
|
err := s.collection.FindOne(ctx, filter).Decode(&record)
|
||||||
if err == mongo.ErrNoDocuments {
|
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user