Created
May 10, 2013 05:52
-
-
Save bradhe/5552633 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ go build | |
| ./test.go:10: cannot type switch on non-interface value slice (type []string) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| func main() { | |
| slice := make([]string, 0) | |
| switch slice.(type) { | |
| case []string: { | |
| fmt.Println("It's a slice!") | |
| } | |
| case map[string] interface{}: { | |
| fmt.Println("It's a map!") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment