Skip to content

Commit

Permalink
pkg/trace/flags: move flag.Parse to main.main (DataDog#4190)
Browse files Browse the repository at this point in the history
Due to a recent change in go1.13 (golang/go#21051), parsing of
flags inside `init` functions causes tests to fail. This change moves
`flag.Parse` inside `main.main`.

For more information see golang/go#33190
  • Loading branch information
gbbr committed Sep 23, 2019
1 parent 0bfc377 commit 1f53c50
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/trace-agent/main_nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package main

import (
"context"
"flag"

"github.com/DataDog/datadog-agent/pkg/trace/agent"
"github.com/DataDog/datadog-agent/pkg/trace/watchdog"
Expand All @@ -24,5 +25,7 @@ func main() {
handleSignal(cancelFunc)
}()

flag.Parse()

agent.Run(ctx)
}
3 changes: 3 additions & 0 deletions cmd/trace-agent/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package main

import (
"context"
"flag"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -93,6 +94,8 @@ func runService(isDebug bool) {

// main is the main application entry point
func main() {
flag.Parse()

isIntSess, err := svc.IsAnInteractiveSession()
if err != nil {
fmt.Printf("failed to determine if we are running in an interactive session: %v", err)
Expand Down
2 changes: 0 additions & 2 deletions pkg/trace/flags/flags_z.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,4 @@ func init() {
flag.StringVar(&MemProfile, "memprofile", "", "Write memory profile to `file`")

registerOSSpecificFlags()

flag.Parse()
}

0 comments on commit 1f53c50

Please sign in to comment.