Skip to content

Commit 88d8954

Browse files
feat: add Go language support with golangci-lint configuration and update Makefile for linting
1 parent d2d70ce commit 88d8954

5 files changed

Lines changed: 45 additions & 4 deletions

File tree

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"golang.Go"
4+
]
5+
}

.vscode/settings.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,23 @@
1616
"test*.py"
1717
],
1818
"python.testing.pytestEnabled": false,
19-
"python.testing.unittestEnabled": true
19+
"python.testing.unittestEnabled": true,
20+
"go.useLanguageServer": true,
21+
"go.toolsManagement.autoUpdate": true,
22+
"go.lintTool": "golangci-lint",
23+
"go.lintFlags": [
24+
"--config=${workspaceFolder}/apps/node-disk-janitor/.golangci.yml"
25+
],
26+
"gopls": {
27+
"formatting.gofumpt": true,
28+
"ui.semanticTokens": true,
29+
"staticcheck": true
30+
},
31+
"[go]": {
32+
"editor.defaultFormatter": "golang.Go",
33+
"editor.formatOnSave": true,
34+
"editor.codeActionsOnSave": {
35+
"source.organizeImports": "explicit"
36+
}
37+
}
2038
}

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ SSH_HOST ?= 76.13.108.14
1111
SSH_PORT ?= 22
1212
REMOTE_K3S_CMD ?= k3s ctr images import -
1313
SSH ?= ssh -p $(SSH_PORT) $(SSH_USER)@$(SSH_HOST)
14+
GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint
1415

15-
.PHONY: help lint deploy status e2e undeploy build-images import-images restart-apps fix-images logs-user logs-product logs-order logs-all logs-since import-images-remote deploy-remote fix-images-remote neon-plan neon-apply neon-destroy k3s-spot-plan k3s-spot-apply k3s-spot-destroy db-format db-validate db-generate db-migrate-status db-migrate-all concurrency-smoke concurrency-idempotency-lite concurrency-hotspot-100tps concurrency-baseline concurrency-stress100 concurrency-stress200 concurrency-hotspot require-tf-remote-state
16+
.PHONY: help lint lint-go deploy status e2e undeploy build-images import-images restart-apps fix-images logs-user logs-product logs-order logs-all logs-since import-images-remote deploy-remote fix-images-remote neon-plan neon-apply neon-destroy k3s-spot-plan k3s-spot-apply k3s-spot-destroy db-format db-validate db-generate db-migrate-status db-migrate-all concurrency-smoke concurrency-idempotency-lite concurrency-hotspot-100tps concurrency-baseline concurrency-stress100 concurrency-stress200 concurrency-hotspot require-tf-remote-state
1617

1718
TAIL ?= 200
1819
SINCE ?= 10m
1920

2021
help:
2122
>echo "Targets:"
2223
>echo " make lint # Run repo lint and shared pylint checks"
24+
>echo " make lint-go # Run golangci-lint for node-disk-janitor"
2325
>echo " make deploy # Deploy chart to local k3s"
2426
>echo " make status # Show pods and services"
2527
>echo " make e2e # Run E2E smoke test"
@@ -58,6 +60,9 @@ help:
5860
lint:
5961
>cd application/flashsale && uv run pre-commit run --all-files
6062

63+
lint-go:
64+
>cd apps/node-disk-janitor && $(GOLANGCI_LINT) run --config .golangci.yml ./...
65+
6166
concurrency-smoke concurrency-idempotency-lite concurrency-hotspot-100tps concurrency-baseline concurrency-stress100 concurrency-stress200 concurrency-hotspot:
6267
>$(MAKE) -C application/flashsale $@
6368

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: "2"
2+
3+
run:
4+
timeout: 3m
5+
tests: true
6+
7+
linters:
8+
enable:
9+
- errcheck
10+
- govet
11+
- ineffassign
12+
- staticcheck
13+
- unused

apps/node-disk-janitor/predicates.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func isTerminatedPod(pod corev1.Pod, cutoff time.Time) bool {
1919
return false
2020
}
2121

22-
if pod.Status.StartTime != nil && pod.Status.StartTime.Time.After(cutoff) {
22+
if pod.Status.StartTime != nil && pod.Status.StartTime.After(cutoff) {
2323
return false
2424
}
2525

@@ -65,7 +65,7 @@ func isNamespaceCleanupCandidate(namespace corev1.Namespace, cutoff time.Time, p
6565
if namespace.DeletionTimestamp != nil || namespace.Status.Phase != corev1.NamespaceActive {
6666
return false
6767
}
68-
if namespace.CreationTimestamp.Time.After(cutoff) {
68+
if namespace.CreationTimestamp.After(cutoff) {
6969
return false
7070
}
7171
return !slices.Contains(protected, namespace.Name)

0 commit comments

Comments
 (0)