libgo/go/runtime/testdata/testprog/abort.go
raw| 1 | // Copyright 2018 The Go Authors. 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 | |
| 5 | package main |
| 6 | |
| 7 | import _ "unsafe" // for go:linkname |
| 8 | |
| 9 | func init() { |
| 10 | register("Abort", Abort) |
| 11 | } |
| 12 | |
| 13 | //go:linkname runtimeAbort runtime.abort |
| 14 | func runtimeAbort() |
| 15 | |
| 16 | func Abort() { |
| 17 | defer func() { |
| 18 | recover() |
| 19 | panic("BAD: recovered from abort") |
| 20 | }() |
| 21 | runtimeAbort() |
| 22 | println("BAD: after abort") |
| 23 | } |