github.com/traefik/yaegi@v0.15.1/_test/issue-1466.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  func SomeFunc(defaultValue interface{}) interface{} {
     8  	switch v := defaultValue.(type) {
     9  	case string:
    10  		return v + " abc"
    11  	case int:
    12  		return v - 234
    13  	}
    14  	panic("whoops")
    15  }
    16  
    17  func main() {
    18  	fmt.Println(SomeFunc(1234))
    19  	fmt.Println(SomeFunc("test"))
    20  }
    21  
    22  // Output:
    23  // 1000
    24  // test abc