fix: resolve all golangci-lint issues
- Add package comments to all packages (pkg/config, pkg/logger, internal/*, cmd/platform)
- Fix context key warnings by using custom ContextKey type
- Export ContextKey type to avoid unexported-return warnings
- Update all context value operations to use ContextKey instead of string
- Update RequestIDKey() and UserIDKey() to return ContextKey
- Fix error checking issues (errcheck)
- Properly handle os.Chdir errors in defer statements
- Properly handle os.Setenv/os.Unsetenv errors in tests
- Fix security warnings (gosec)
- Change directory permissions from 0755 to 0750 in tests
- Change file permissions from 0644 to 0600 in tests
- Fix unused parameter warnings (revive)
- Replace unused parameters with _ in:
* RegisterLifecycleHooks lifecycle functions
* Mock logger implementations
* noOpLogger methods
- Fix type assertion issues (staticcheck)
- Remove unnecessary type assertions in tests
- Use simpler compile-time checks
- Fix exported type stuttering warning
- Add nolint directive for ConfigProvider (standard interface pattern)
- Update golangci-lint configuration
- Add version: 2 field (required for newer versions)
- Remove unsupported linters (typecheck, gosimple)
- Move formatters (gofmt, goimports) to separate formatters section
- Simplify linter list to only well-supported linters
All linting issues resolved (0 issues reported by golangci-lint).
All tests pass and code compiles successfully.
This commit is contained in:
@@ -80,7 +80,7 @@ func TestRequestIDFromContext(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "with request ID",
|
||||
ctx: context.WithValue(context.Background(), RequestIDKey(), "test-id"),
|
||||
ctx: context.WithValue(context.Background(), requestIDKey, "test-id"),
|
||||
want: "test-id",
|
||||
wantEmpty: false,
|
||||
},
|
||||
@@ -92,7 +92,7 @@ func TestRequestIDFromContext(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "with wrong type",
|
||||
ctx: context.WithValue(context.Background(), RequestIDKey(), 123),
|
||||
ctx: context.WithValue(context.Background(), requestIDKey, 123),
|
||||
want: "",
|
||||
wantEmpty: true,
|
||||
},
|
||||
@@ -160,7 +160,7 @@ func TestUserIDFromContext(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "with user ID",
|
||||
ctx: context.WithValue(context.Background(), UserIDKey(), "user-123"),
|
||||
ctx: context.WithValue(context.Background(), userIDKey, "user-123"),
|
||||
want: "user-123",
|
||||
wantEmpty: false,
|
||||
},
|
||||
@@ -172,7 +172,7 @@ func TestUserIDFromContext(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "with wrong type",
|
||||
ctx: context.WithValue(context.Background(), UserIDKey(), 123),
|
||||
ctx: context.WithValue(context.Background(), userIDKey, 123),
|
||||
want: "",
|
||||
wantEmpty: true,
|
||||
},
|
||||
@@ -303,7 +303,7 @@ func TestRequestIDMiddleware_MultipleRequests(t *testing.T) {
|
||||
func TestSetRequestID_Overwrite(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := context.WithValue(context.Background(), RequestIDKey(), "old-id")
|
||||
ctx := context.WithValue(context.Background(), requestIDKey, "old-id")
|
||||
newCtx := SetRequestID(ctx, "new-id")
|
||||
|
||||
requestID := RequestIDFromContext(newCtx)
|
||||
@@ -315,7 +315,7 @@ func TestSetRequestID_Overwrite(t *testing.T) {
|
||||
func TestSetUserID_Overwrite(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := context.WithValue(context.Background(), UserIDKey(), "old-user")
|
||||
ctx := context.WithValue(context.Background(), userIDKey, "old-user")
|
||||
newCtx := SetUserID(ctx, "new-user")
|
||||
|
||||
userID := UserIDFromContext(newCtx)
|
||||
@@ -350,10 +350,10 @@ func (m *mockLoggerForMiddleware) Error(msg string, fields ...logger.Field) {
|
||||
m.logs = append(m.logs, logEntry{message: msg, fields: fields})
|
||||
}
|
||||
|
||||
func (m *mockLoggerForMiddleware) With(fields ...logger.Field) logger.Logger {
|
||||
func (m *mockLoggerForMiddleware) With(_ ...logger.Field) logger.Logger {
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *mockLoggerForMiddleware) WithContext(ctx context.Context) logger.Logger {
|
||||
func (m *mockLoggerForMiddleware) WithContext(_ context.Context) logger.Logger {
|
||||
return m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user