Skip to content

Instantly share code, notes, and snippets.

@zimbatm
Created February 14, 2010 13:37
Show Gist options
  • Save zimbatm/304025 to your computer and use it in GitHub Desktop.
Save zimbatm/304025 to your computer and use it in GitHub Desktop.
$ 6g mapkey.go
$ 6l mapkey.6
$ ./6.out
throw: runtime.mapaccess1: key not in map
panic PC=0x299ff8
throw+0x3e /Users/zimbatm/Code/golang/src/pkg/runtime/runtime.c:74
throw(0x4ae9d, 0x0)
runtime.mapaccess1+0x74 /Users/zimbatm/Code/golang/src/pkg/runtime/hashmap.c:772
runtime.mapaccess1(0x2a8230, 0x0)
main.main+0xb5 /Users/zimbatm/Code/learn/golang/mapkey.go:8
main.main()
mainstart+0xf /Users/zimbatm/Code/golang/src/pkg/runtime/amd64/asm.s:54
mainstart()
goexit /Users/zimbatm/Code/golang/src/pkg/runtime/proc.c:140
goexit()
package main
import "fmt"
func main() {
var myMap = make(map[string]string);
myMap["message"] = "world";
fmt.Printf("hello, %s\n", myMap["wrongkey"])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment