Skip to content

Commit

Permalink
build: add build constraint to restrict promslog to go1.21+
Browse files Browse the repository at this point in the history
We still support go1.20 in the test matrix, but slog was only added to
the go standard library in go1.21. The build constraints allow us to
continue supporting go1.20 for the rest of the existing library, at the
cost of only supporting promslog for go1.21+.

Signed-off-by: TJ Hoplock <[email protected]>
  • Loading branch information
tjhop committed Aug 17, 2024
1 parent 8e18295 commit c3622e1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions promslog/flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// across Prometheus components.
// It should typically only ever be imported by main packages.

//go:build go1.21

package flag

import (
Expand Down
3 changes: 3 additions & 0 deletions promslog/slog.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// Package promslog defines standardised ways to initialize the Go standard
// library's log/slog logger.
// It should typically only ever be imported by main packages.

//go:build go1.21

package promslog

import (
Expand Down
2 changes: 2 additions & 0 deletions promslog/slog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build go1.21

package promslog

import (
Expand Down

0 comments on commit c3622e1

Please sign in to comment.