3
interface{}
이 알려진 키/값 유형의지도입니다 여부를 테스트 할 수 있지만 : 주요 신경 쓰지 않고키/값 유형을 모른 채 인터페이스 {}가지도인지 테스트하는 방법은 무엇입니까?
func TypeTest(thing interface{}) {
switch thing.(type) {
case map[string]string:
fmt.Println("map string string")
case map[string]interface{}:
fmt.Println("map string")
case map[interface{}]interface{}:
fmt.Println("map")
case interface{}:
fmt.Println("interface")
default:
fmt.Println("unknown")
}
}
TypeTest(map[string]string{"a": "1"}) // "map string string"
TypeTest(map[string]int{"a": 1}) // "interface" !!!
하지만 제가 그냥 interface{}
이지도인지 여부를 알고 싶다면/값 유형?
는 http://play.golang.org/p/6hm_ZxZDmZ – deemok
나는 당신이, deemok, 대단히 감사합니다 것 같아! –