All checks were successful
check / check (push) Successful in 5s
Clears the final 80 golangci-lint findings under the canonical .golangci.yml (sha256 021cc83f4e6fc7c31b95b34b846723dfcf20b66b7baeea1dc40406e643346bcb), taking the repo from red to green: script/cibuild exits 0. - wsl_v5 (60): blank line above defer/go statements sharing no variable with the line above; blank-line-only diff. - sqlclosecheck (10): the package-local CloseRows helper hid the close from the analyzer. Helper removed; all 18 call sites now defer an inline rows.Close(), preserving the fatal-on-close-error path. No resource leak existed - the rows were always being closed. - prealloc (3): append targets given a starting capacity. - revive (3): package-name findings suppressed with per-site directives pending the naming decision tracked in #76. No gosec suppressions are needed under the pinned linter. .golangci.yml, Dockerfile, Makefile, .gitea/ and script/ are byte-identical to main. Verified with script/cibuild (digest-pinned golangci-lint v2.12.2), not make check - the latter resolves the linter from PATH and is not a trustworthy gate here; see #78. Closes #59.
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Package main is the vaultik command-line entry point.
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
"runtime/pprof"
|
|
|
|
"sneak.berlin/go/vaultik/internal/cli"
|
|
)
|
|
|
|
func main() {
|
|
// CPU profiling: set VAULTIK_CPUPROFILE=/path/to/cpu.prof
|
|
if cpuProfile := os.Getenv("VAULTIK_CPUPROFILE"); cpuProfile != "" {
|
|
f, err := os.Create(cpuProfile) //nolint:gosec // G304: operator-set path
|
|
if err != nil {
|
|
panic("could not create CPU profile: " + err.Error())
|
|
}
|
|
|
|
defer func() { _ = f.Close() }()
|
|
|
|
err = pprof.StartCPUProfile(f)
|
|
if err != nil {
|
|
panic("could not start CPU profile: " + err.Error())
|
|
}
|
|
|
|
defer pprof.StopCPUProfile()
|
|
}
|
|
|
|
// Memory profiling: set VAULTIK_MEMPROFILE=/path/to/mem.prof
|
|
if memProfile := os.Getenv("VAULTIK_MEMPROFILE"); memProfile != "" {
|
|
defer func() {
|
|
f, err := os.Create(memProfile) //nolint:gosec // G304: operator-set path
|
|
if err != nil {
|
|
panic("could not create memory profile: " + err.Error())
|
|
}
|
|
|
|
defer func() { _ = f.Close() }()
|
|
|
|
runtime.GC() // get up-to-date statistics
|
|
|
|
err = pprof.WriteHeapProfile(f)
|
|
if err != nil {
|
|
panic("could not write memory profile: " + err.Error())
|
|
}
|
|
}()
|
|
}
|
|
|
|
cli.Entry()
|
|
}
|