Compare commits

...

2 Commits

Author SHA1 Message Date
7e2b50faf0 update .vscode settings 2026-04-08 19:31:36 +00:00
9ea29d3ba4 rename.sh: keep gitea.djmil.dev/go/template/pkg/result 2026-04-08 19:14:41 +00:00
4 changed files with 20 additions and 20 deletions

View File

@ -1,12 +1,10 @@
{ {
// Go // Go
"go.useLanguageServer": true,
"go.lintTool": "golangci-lint", "go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast"], "go.lintFlags": ["--fast"],
"go.lintOnSave": "workspace", "go.lintOnSave": "workspace",
"go.testFlags": ["-race"], "go.testFlags": ["-race"],
"go.coverOnSave": false, "go.coverOnSave": false,
"go.generateOnSave": false,
// Editor // Editor
"[go]": { "[go]": {
@ -16,9 +14,6 @@
"source.organizeImports": "explicit" "source.organizeImports": "explicit"
} }
}, },
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
// Files // Files
"files.exclude": { "files.exclude": {
@ -27,16 +22,15 @@
}, },
"search.exclude": { "search.exclude": {
"**/bin": true, "**/bin": true,
"**/mocks": true,
"**/vendor": true "**/vendor": true
}, },
// Test explorer // Test explorer
"go.testExplorer.enable": true, "go.testExplorer.enable": true,
"makefile.configureOnOpen": false,
"cSpell.words": [ "cSpell.words": [
"djmil", "djmil",
"gitea", "gitea",
"golangci",
"testutil" "testutil"
] ]
} }

7
.vscode/tasks.json vendored
View File

@ -41,13 +41,6 @@
"presentation": { "reveal": "always", "panel": "shared" }, "presentation": { "reveal": "always", "panel": "shared" },
"problemMatcher": "$go" "problemMatcher": "$go"
}, },
{
"label": "mocks",
"type": "shell",
"command": "make mocks",
"group": "none",
"presentation": { "reveal": "always", "panel": "shared" }
},
{ {
"label": "security scan", "label": "security scan",
"type": "shell", "type": "shell",

View File

@ -126,11 +126,24 @@ sedi() {
fi fi
} }
# ── Helper: rename module path in a file, preserving pkg/result imports ───────
# pkg/result is a standalone publishable package; its import path must not
# change when the consuming project is renamed.
RESULT_PKG="${OLD_MODULE}/pkg/result"
PLACEHOLDER="__RESULT_PKG_PLACEHOLDER__"
rename_module_in() {
local file="$1"
sedi "s|${RESULT_PKG}|${PLACEHOLDER}|g" "$file"
sedi "s|${OLD_MODULE}|${NEW_MODULE}|g" "$file"
sedi "s|${PLACEHOLDER}|${RESULT_PKG}|g" "$file"
}
# ── Apply substitutions ─────────────────────────────────────────────────────── # ── Apply substitutions ───────────────────────────────────────────────────────
heading "Applying changes" heading "Applying changes"
# 1. go.mod — module declaration # 1. go.mod — module declaration
sedi "s|${OLD_MODULE}|${NEW_MODULE}|g" go.mod rename_module_in go.mod
info "go.mod" info "go.mod"
# 2. All Go source files — import paths # 2. All Go source files — import paths
@ -143,7 +156,7 @@ GO_FILES=$(find . \
CHANGED_GO=0 CHANGED_GO=0
for f in $GO_FILES; do for f in $GO_FILES; do
if grep -q "$OLD_MODULE" "$f" 2>/dev/null; then if grep -q "$OLD_MODULE" "$f" 2>/dev/null; then
sedi "s|${OLD_MODULE}|${NEW_MODULE}|g" "$f" rename_module_in "$f"
CHANGED_GO=$((CHANGED_GO + 1)) CHANGED_GO=$((CHANGED_GO + 1))
fi fi
done done
@ -159,19 +172,19 @@ fi
# 4. README.md — heading + all module path occurrences # 4. README.md — heading + all module path occurrences
if [[ -f README.md ]]; then if [[ -f README.md ]]; then
sedi "s|^# ${OLD_PROJECT}$|# ${NEW_PROJECT}|g" README.md sedi "s|^# ${OLD_PROJECT}$|# ${NEW_PROJECT}|g" README.md
sedi "s|${OLD_MODULE}|${NEW_MODULE}|g" README.md rename_module_in README.md
info "README.md" info "README.md"
fi fi
# 5. CLAUDE.md — Module line # 5. CLAUDE.md — Module line
if [[ -f CLAUDE.md ]]; then if [[ -f CLAUDE.md ]]; then
sedi "s|${OLD_MODULE}|${NEW_MODULE}|g" CLAUDE.md rename_module_in CLAUDE.md
info "CLAUDE.md" info "CLAUDE.md"
fi fi
# 6. .golangci.yml — goimports local-prefixes # 6. .golangci.yml — goimports local-prefixes
if [[ -f .golangci.yml ]]; then if [[ -f .golangci.yml ]]; then
sedi "s|${OLD_MODULE}|${NEW_MODULE}|g" .golangci.yml rename_module_in .golangci.yml
info ".golangci.yml" info ".golangci.yml"
fi fi