2015-01-01から1日間の記事一覧

golangのType Assertionメモ

Type AssertionはC++のdynamic_cast的な機能。 interfaceを別の型にキャストする時に使用。 2通りの受け方がある。 package main import ( "fmt" "errors" ) type MyError struct { i int } func (e *MyError) Error() string { return fmt.Sprintf("i = %d"…