Skip to content

Instantly share code, notes, and snippets.

@pfeilbr
Created October 14, 2016 18:13
Show Gist options
  • Save pfeilbr/2308aa6e5a90344d1c383712de8c9f8c to your computer and use it in GitHub Desktop.
Save pfeilbr/2308aa6e5a90344d1c383712de8c9f8c to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"testing"
)
func TestSliceTypeAssertion(t *testing.T) {
fn := func(v interface{}) {
switch typ := v.(type) {
default:
fmt.Printf("typ: %v\n", typ) // output: typ: [milk eggs cheese]
}
}
items := []string{"milk", "eggs", "cheese"}
fn(items)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment