| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package assume_no_moving_gc |
| 9 |
|
| 10 |
import ( |
| 11 |
"os" |
| 12 |
_ "unsafe" |
| 13 |
) |
| 14 |
|
| 15 |
|
| 16 |
func heapObjectsCanMove() bool |
| 17 |
|
| 18 |
func init() { |
| 19 |
if !heapObjectsCanMove() { |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
return |
| 25 |
} |
| 26 |
if os.Getenv(env) == "play-with-fire" { |
| 27 |
return |
| 28 |
} |
| 29 |
panic(` |
| 30 |
Something in this program imports go4.org/unsafe/assume-no-moving-gc to |
| 31 |
declare that it assumes a non-moving garbage collector, but the version |
| 32 |
of Go you're using declares that its heap objects can now move around. |
| 33 |
This program is no longer safe. You should update your packages which import |
| 34 |
go4.org/unsafe/assume-no-moving-gc. To risk it and bypass this check, set |
| 35 |
ASSUME_NO_MOVING_GC_UNSAFE=play-with-fire and cross your fingers.`) |
| 36 |
} |