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