@kjk1/

gobook recover

Go

No description

fork
loading
Files
  • main.go

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.12935445330473194","path":"main.go","file":{"path":"main.go","content":{"asEncoding":{"base64":"Ly8gYWxsb3cgZXJyb3IKcGFja2FnZSBtYWluCgppbXBvcnQgImZtdCIKCi8vIDpzaG93IHN0YXJ0CmZ1bmMgZm9vKCkgewoJcGFuaWMoImJhciIpCn0KCmZ1bmMgYmFyKCkgewoJZGVmZXIgZnVuYygpIHsKCQlpZiBtc2cgOj0gcmVjb3ZlcigpOyBtc2cgIT0gbmlsIHsKCQkJZm10LlByaW50ZigiUmVjb3ZlcmVkIHdpdGggbWVzc2FnZSAlc1xuIiwgbXNnKQoJCX0KCX0oKQoJZm9vKCkKCWZtdC5QcmludGxuKCJOZXZlciBnZXRzIGV4ZWN1dGVkIikKfQoKZnVuYyBtYWluKCkgewoJZm10LlByaW50bG4oIkVudGVyaW5nIG1haW4iKQoJYmFyKCkKCWZtdC5QcmludGxuKCJFeGl0aW5nIG1haW4gdGhlIG5vcm1hbCB3YXkiKQp9CgovLyA6c2hvdyBlbmQ="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// allow error
package main

import "fmt"

// :show start
func foo() {
	panic("bar")
}

func bar() {
	defer func() {
		if msg := recover(); msg != nil {
			fmt.Printf("Recovered with message %s\n", msg)
		}
	}()
	foo()
	fmt.Println("Never gets executed")
}

func main() {
	fmt.Println("Entering main")
	bar()
	fmt.Println("Exiting main the normal way")
}

// :show end