Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion version/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ func computeRevision() (string, string) {
tags = "unknown"
modified bool
)
if race {
tags = "race"
}

buildInfo, ok := debug.ReadBuildInfo()
if !ok {
Expand All @@ -141,7 +144,11 @@ func computeRevision() (string, string) {
}
}
if v.Key == "-tags" {
tags = v.Value
if race {
tags = v.Value + ",race"
} else {
tags = v.Value
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is an easier way of doing this.

If the race detector is enabled, the buildInfo.Settings contain an entry -race=true. So we simply need something like

		if v.Key == "-race" && v.Value == "true" {

with the appropriate flow later to assemble the right tags string, as we cannot expect a certain order of the -tags key and the -race key.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done at bd03eb9.

}
}
if modified {
Expand Down
18 changes: 18 additions & 0 deletions version/info_norace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !race

package version

const race = false
18 changes: 18 additions & 0 deletions version/info_race.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build race

package version

const race = true
Loading