開発環境
- macOS High Sierra - Apple
- Emacs (Text Editor)
- Go (プログラミング言語)
- Introducing Go: Build Reliable, Scalable Programs Caleb Doxsey (著) (参考書籍)
入門 Python 3 (Bill Lubanovic (著)、斎藤 康毅 (監修)、長尾 高弘 (翻訳)、オライリージャパン)の4章(Pyの皮: コード構造)、4.13(復習問題)4-11.をGoで取り組んでみる。
コード(Emacs)
package main
import "fmt"
func main() {
defer func() {
fmt.Println("defer")
msg := recover()
fmt.Println(msg)
}()
panic("Caught an opps")
}
入出力結果(Terminal)
$ go run sample5.go defer Caught an opps $
0 コメント:
コメントを投稿