diff options
author | scaiper <scaiper@nebius.com> | 2024-03-24 22:40:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-24 20:40:13 +0100 |
commit | 2343e4a6e40e26d94218f425398bdc807cdc0354 (patch) | |
tree | 1ed8fe479992b3822ee827d0f9a8440cb3ca1d24 | |
parent | 5a0e2c748a22d0da78f65e39b69f1467966a51c6 (diff) | |
download | bazelbuild-rules_go-2343e4a6e40e26d94218f425398bdc807cdc0354.tar.gz |
[nogo] match regexp againts relative paths (#3898)
-rw-r--r-- | go/tools/builders/nogo_main.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/go/tools/builders/nogo_main.go b/go/tools/builders/nogo_main.go index 23acdef0..d2821774 100644 --- a/go/tools/builders/nogo_main.go +++ b/go/tools/builders/nogo_main.go @@ -32,6 +32,7 @@ import ( "io/ioutil" "log" "os" + "path/filepath" "reflect" "regexp" "sort" @@ -442,6 +443,10 @@ func checkAnalysisResults(actions []*action, pkg *goPackage) string { } var diagnostics []entry var errs []error + cwd, err := os.Getwd() + if cwd == "" || err != nil { + errs = append(errs, fmt.Errorf("nogo failed to get CWD: %w", err)) + } for _, act := range actions { if act.err != nil { // Analyzer failed. @@ -485,6 +490,11 @@ func checkAnalysisResults(actions []*action, pkg *goPackage) string { if p.IsValid() { filename = p.Filename } + if cwd != "" { + if relname, err := filepath.Rel(cwd, filename); err == nil { + filename = relname + } + } include := true if len(currentConfig.onlyFiles) > 0 { // This analyzer emits diagnostics for only a set of files. |