untested.go 886 B

1234567891011121314151617181920212223242526
  1. // Copyright 2020 Brad Fitzpatrick. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //go:build go1.20
  5. // +build go1.20
  6. package assume_no_moving_gc
  7. import (
  8. "os"
  9. "runtime"
  10. "strings"
  11. )
  12. func init() {
  13. dots := strings.SplitN(runtime.Version(), ".", 3)
  14. v := runtime.Version()
  15. if len(dots) >= 2 {
  16. v = dots[0] + "." + dots[1]
  17. }
  18. if os.Getenv(env) == v {
  19. return
  20. }
  21. panic("Something in this program imports go4.org/unsafe/assume-no-moving-gc to declare that it assumes a non-moving garbage collector, but your version of go4.org/unsafe/assume-no-moving-gc hasn't been updated to assert that it's safe against the " + v + " runtime. If you want to risk it, run with environment variable " + env + "=" + v + " set. Notably, if " + v + " adds a moving garbage collector, this program is unsafe to use.")
  22. }