github.com/tidwall/go@v0.0.0-20170415222209-6694a6888b7d/src/runtime/testdata/testprog/syscall_windows.go (about)

     1  // Copyright 2015 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 "syscall"
     8  
     9  func init() {
    10  	register("RaiseException", RaiseException)
    11  	register("ZeroDivisionException", ZeroDivisionException)
    12  }
    13  
    14  func RaiseException() {
    15  	const EXCEPTION_NONCONTINUABLE = 1
    16  	mod := syscall.MustLoadDLL("kernel32.dll")
    17  	proc := mod.MustFindProc("RaiseException")
    18  	proc.Call(0xbad, EXCEPTION_NONCONTINUABLE, 0, 0)
    19  	println("RaiseException should not return")
    20  }
    21  
    22  func ZeroDivisionException() {
    23  	x := 1
    24  	y := 0
    25  	z := x / y
    26  	println(z)
    27  }