chore(backend): improve linter and formater settings for backend

This commit is contained in:
Daniel Aschwanden
2026-04-16 21:48:38 +02:00
parent 6164f8f273
commit db1bfeba27
7 changed files with 72 additions and 8 deletions
+33
View File
@@ -0,0 +1,33 @@
version: "2"
linters:
default: standard
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
settings:
gci:
sections:
- standard # Standard section: captures all standard packages.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/f-eld-ch) # Custom section: groups all imports with the specified Prefix.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
# Checks that no inline comments are present.
# Default: false
no-inline-comments: true
# Checks that no prefix comments (comment lines above an import) are present.
# Default: false
no-prefix-comments: true
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
# Drops lexical ordering for custom sections.
# Default: false
no-lex-order: true
+28 -1
View File
@@ -23,4 +23,31 @@
"source.fixAll.oxc": "always",
},
},
}
// Go Settings
"go.useLanguageServer": true,
"go.lintTool": "golangci-lint",
"go.lintFlags": [
"--path-mode=abs",
"--fast-only"
],
"go.formatTool": "custom",
"go.alternateTools": {
"customFormatter": "golangci-lint"
},
"go.formatFlags": [
"fmt",
"--stdin"
],
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
},
},
"gopls": {
"formatting.gofumpt": false,
"formatting.local": "github.com/f-eld-ch/sitrep",
},
}
+2 -1
View File
@@ -8,9 +8,10 @@ import (
"log/slog"
"net/http"
"github.com/spf13/viper"
"github.com/f-eld-ch/sitrep/server"
"github.com/f-eld-ch/sitrep/server/auth"
"github.com/spf13/viper"
)
// Version is the version of the application, set at build time.
+2 -1
View File
@@ -8,6 +8,8 @@ import (
"time"
slogmulti "github.com/samber/slog-multi"
semconv "go.opentelemetry.io/otel/semconv/v1.40.0"
"go.opentelemetry.io/contrib/bridges/otelslog"
"go.opentelemetry.io/contrib/instrumentation/runtime"
"go.opentelemetry.io/otel"
@@ -20,7 +22,6 @@ import (
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/resource"
"go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.40.0"
)
func setupOpenTelemetry(ctx context.Context) (shutdown func(context.Context) error, err error) {
+3 -3
View File
@@ -7,16 +7,16 @@ import (
"net/http"
"time"
httphelper "github.com/zitadel/oidc/v3/pkg/http"
semconv "go.opentelemetry.io/otel/semconv/v1.40.0"
"github.com/google/uuid"
"github.com/gorilla/securecookie"
"github.com/labstack/echo/v4"
"github.com/zitadel/oidc/v3/pkg/client"
"github.com/zitadel/oidc/v3/pkg/client/rp"
httphelper "github.com/zitadel/oidc/v3/pkg/http"
"github.com/zitadel/oidc/v3/pkg/oidc"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
semconv "go.opentelemetry.io/otel/semconv/v1.40.0"
"go.opentelemetry.io/otel/trace"
)
+2 -1
View File
@@ -4,10 +4,11 @@ import (
"net/http"
"net/url"
"github.com/f-eld-ch/sitrep/server/auth"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"github.com/f-eld-ch/sitrep/server/auth"
)
// Option defines a functional option for Server.
+2 -1
View File
@@ -4,10 +4,11 @@ import (
"net/http"
"strings"
"github.com/f-eld-ch/sitrep/ui"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho"
"github.com/f-eld-ch/sitrep/ui"
)
// Routes registers all HTTP routes and handlers on the server's router.