github.com/traefik/yaegi@v0.15.1/stdlib/maptypes.go (about) 1 package stdlib 2 3 import ( 4 "encoding" 5 "encoding/json" 6 "encoding/xml" 7 "fmt" 8 "log" 9 "reflect" 10 ) 11 12 func init() { 13 mt := []reflect.Type{ 14 reflect.TypeOf((*fmt.Formatter)(nil)).Elem(), 15 reflect.TypeOf((*fmt.Stringer)(nil)).Elem(), 16 } 17 18 MapTypes[reflect.ValueOf(fmt.Errorf)] = mt 19 MapTypes[reflect.ValueOf(fmt.Fprint)] = mt 20 MapTypes[reflect.ValueOf(fmt.Fprintf)] = mt 21 MapTypes[reflect.ValueOf(fmt.Fprintln)] = mt 22 MapTypes[reflect.ValueOf(fmt.Print)] = mt 23 MapTypes[reflect.ValueOf(fmt.Printf)] = mt 24 MapTypes[reflect.ValueOf(fmt.Println)] = mt 25 MapTypes[reflect.ValueOf(fmt.Sprint)] = mt 26 MapTypes[reflect.ValueOf(fmt.Sprintf)] = mt 27 MapTypes[reflect.ValueOf(fmt.Sprintln)] = mt 28 29 MapTypes[reflect.ValueOf(log.Fatal)] = mt 30 MapTypes[reflect.ValueOf(log.Fatalf)] = mt 31 MapTypes[reflect.ValueOf(log.Fatalln)] = mt 32 MapTypes[reflect.ValueOf(log.Panic)] = mt 33 MapTypes[reflect.ValueOf(log.Panicf)] = mt 34 MapTypes[reflect.ValueOf(log.Panicln)] = mt 35 36 mt = []reflect.Type{reflect.TypeOf((*fmt.Scanner)(nil)).Elem()} 37 38 MapTypes[reflect.ValueOf(fmt.Scan)] = mt 39 MapTypes[reflect.ValueOf(fmt.Scanf)] = mt 40 MapTypes[reflect.ValueOf(fmt.Scanln)] = mt 41 42 MapTypes[reflect.ValueOf(json.Marshal)] = []reflect.Type{ 43 reflect.TypeOf((*json.Marshaler)(nil)).Elem(), 44 reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem(), 45 } 46 MapTypes[reflect.ValueOf(json.Unmarshal)] = []reflect.Type{ 47 reflect.TypeOf((*json.Unmarshaler)(nil)).Elem(), 48 reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem(), 49 } 50 MapTypes[reflect.ValueOf(xml.Marshal)] = []reflect.Type{ 51 reflect.TypeOf((*xml.Marshaler)(nil)).Elem(), 52 reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem(), 53 } 54 MapTypes[reflect.ValueOf(xml.Unmarshal)] = []reflect.Type{ 55 reflect.TypeOf((*xml.Unmarshaler)(nil)).Elem(), 56 reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem(), 57 } 58 }