|
|
@@ -14,6 +14,8 @@ import ( |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/google/uuid" |
|
|
|
) |
|
|
|
|
|
|
|
var errNegativeNotAllowed = errors.New("unable to cast negative value") |
|
|
@@ -756,6 +758,24 @@ func ToUint8E(i interface{}) (uint8, error) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// ToUUIDE casts an interface to a uint type. |
|
|
|
func ToUUIDE(i interface{}) (uuid.UUID, error) { |
|
|
|
i = indirect(i) |
|
|
|
var b uuid.UUID |
|
|
|
|
|
|
|
switch s := i.(type) { |
|
|
|
case string: |
|
|
|
return uuid.Parse(s) |
|
|
|
case interface{}: |
|
|
|
if str, err := ToStringE(s); err == nil { |
|
|
|
return uuid.Parse(str) |
|
|
|
} |
|
|
|
return b, fmt.Errorf("unable to cast %#v of type %T to UUID", i, i) |
|
|
|
default: |
|
|
|
return b, fmt.Errorf("unable to cast %#v of type %T to UUID", i, i) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// From html/template/content.go |
|
|
|
// Copyright 2011 The Go Authors. All rights reserved. |
|
|
|
// indirect returns the value, after dereferencing as many times |
|
|
|