Skip to content

Commit

Permalink
all: consistently use cpu_profile as flag name (#895)
Browse files Browse the repository at this point in the history
This is more a workaround since a transitive dependency has introduced a
global flag "cpuprofile", leading to a panic due to registring the flag
twice.

To make ourselves immune to this issue we can refactor our usages to use
a FlagSet, even for "main". This is a bigger and frankly inconvenient
change for a somewhat rare occurance. Instead we just rename our flag.

I feel comfortable renaming since this flag should only really be used
by Zoekt developers. There will be the issue that the flag will be shown
twice for commands, but I will report to the upstream repo about this
problem.

Test Plan: go get -u ./... && go run ./cmd/zoekt-git-index works
  • Loading branch information
keegancsmith authored Jan 17, 2025
1 parent 21d90f4 commit 3287245
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/zoekt-git-index/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func run() int {
deltaShardNumberFallbackThreshold := flag.Uint64("delta_threshold", 0, "upper limit on the number of preexisting shards that can exist before attempting a delta build (0 to disable fallback behavior)")
languageMap := flag.String("language_map", "", "a mapping between a language and its ctags processor (a:0,b:3).")

cpuProfile := flag.String("cpuprofile", "", "write cpu profile to `file`")
cpuProfile := flag.String("cpu_profile", "", "write cpu profile to `file`")

flag.Parse()

Expand Down
4 changes: 2 additions & 2 deletions cmd/zoekt-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func compare(dir, patfile string, caseSensitive bool) error {
}

var (
memprofile = flag.String("memprofile", "", "write memory profile to `file`")
cpuprofile = flag.String("cpuprofile", "", "write memory profile to `file`")
memprofile = flag.String("mem_profile", "", "write memory profile to `file`")
cpuprofile = flag.String("cpu_profile", "", "write cpu profile to `file`")
)

func testLoadIndexDir(indexDir string) {
Expand Down

0 comments on commit 3287245

Please sign in to comment.