diff --git a/lang/types/type.go b/lang/types/type.go index 888d268f..5805a353 100644 --- a/lang/types/type.go +++ b/lang/types/type.go @@ -31,6 +31,7 @@ package types import ( "fmt" + "net" "reflect" "strings" @@ -184,6 +185,14 @@ func ConfigurableTypeOf(t reflect.Type, opts ...TypeOfOption) (*Type, error) { kind = typ.Kind() } + // Special cases: + if reflect.TypeOf(net.HardwareAddr{}) == typ { + return &Type{ + Kind: KindStr, + }, nil + } + // TODO: net/url.URL, time.Duration, etc. Note: avoid net/mail.Address + switch kind { // match on destination field kind case reflect.Bool: return &Type{ diff --git a/lang/types/value.go b/lang/types/value.go index cf6a8741..bf49de17 100644 --- a/lang/types/value.go +++ b/lang/types/value.go @@ -32,6 +32,7 @@ package types import ( "errors" "fmt" + "net" "reflect" "sort" "strconv" @@ -111,6 +112,14 @@ func ValueOf(v reflect.Value) (Value, error) { value = value.Elem() // XXX: is this correct? } + // Special cases: + if value.CanInterface() { + if v, ok := (value.Interface()).(net.HardwareAddr); ok { + return &StrValue{V: v.String()}, nil + } + } + // TODO: net/url.URL, time.Duration, etc. Note: avoid net/mail.Address + switch kind { // match on destination field kind case reflect.Bool: return &BoolValue{V: value.Bool()}, nil