tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,5 @@
func main() {
if problem {
return
}
}

View file

@ -0,0 +1,46 @@
package main
import (
"fmt"
"runtime"
"time"
)
const problem = true
func main() {
fmt.Println("main program start")
// this will get run on exit
defer paperwork()
// this will not run to completion
go pcj()
// this will not get run on exit
rec := &requiresExternalCleanup{"external object"}
runtime.SetFinalizer(rec, cleanup)
if problem {
fmt.Println("main program returning")
return
}
}
func paperwork() {
fmt.Println("i's dotted, t's crossed")
}
func pcj() {
fmt.Println("there's uncle Joe")
time.Sleep(1e10)
fmt.Println("movin kinda slow")
}
type requiresExternalCleanup struct {
id string
}
func cleanup(rec *requiresExternalCleanup) {
fmt.Println(rec.id, "cleanup")
}

View file

@ -0,0 +1,13 @@
func main() {
fmt.Println("main program start")
// this will not get run on os.Exit
defer func() {
fmt.Println("deferred function")
}()
if problem {
fmt.Println("main program exiting")
os.Exit(-1)
}
}

View file

@ -0,0 +1,17 @@
func pcj() {
fmt.Println("at the junction")
defer func() {
fmt.Println("deferred from pcj")
}()
panic(10)
}
func main() {
fmt.Println("main program start")
defer func() {
fmt.Println("deferred from main")
}()
go pcj()
time.Sleep(1e9)
fmt.Println("main program done")
}