Skip to content

Commit a736992

Browse files
committed
counter: add dummy api for go1.18 or older
internal/counter and internal/mmap use features available only after go1.19/go1.20. Gopls, the first application to use this package, still supports builds with go1.18. Add build constraints and a dummy file to avoid build breakage when gopls starts to use this. And delete interna/counter/bootstrap.go. This was intended to support the go bootstrap build when the internal/counter package was originally in the main Go project. The code is now moved to x/telemetry, and the build constraint don't make sense. Change-Id: Ibd32c6edf9104cfab197272808a701ddd2ff3bb3 Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/504955 Reviewed-by: Jamal Carvalho <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
1 parent c7e1bd3 commit a736992

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

counter/counter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build go1.19
6+
57
package counter
68

79
// The implementation of this package and tests are located in

internal/counter/bootstrap.go renamed to counter/counter_go118.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build compiler_bootstrap
5+
//go:build !go1.19
66

77
package counter
88

9+
import "fmt"
10+
911
func Add(string, int64) {}
1012
func Inc(string) {}
1113
func Open() {}
@@ -23,3 +25,7 @@ type File struct {
2325
}
2426

2527
func Parse(filename string, data []byte) (*File, error) { return nil, fmt.Errorf("unimplemented") }
28+
29+
type StackCounter struct{ name string }
30+
31+
func NewStack(name string, _ int) *StackCounter { return &StackCounter{name} }

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ module golang.org/x/telemetry
33
go 1.20
44

55
require golang.org/x/mod v0.10.0
6+
67
require golang.org/x/sys v0.8.0

0 commit comments

Comments
 (0)