-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
47 lines (40 loc) · 909 Bytes
/
types.go
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
package datatypex
import (
"database/sql"
"database/sql/driver"
"encoding"
"encoding/json"
"reflect"
)
// SqlValue can convert between sql value and describe sql datatype
type SqlValue interface {
driver.Value
sql.Scanner
DataType(engine string) string
}
type TextValue interface {
encoding.TextUnmarshaler
encoding.TextMarshaler
}
type JSONValue interface {
json.Unmarshaler
json.Marshaler
}
// Assertions
var (
_ SqlValue = (*Address)(nil)
_ SqlValue = (*Timestamp)(nil)
_ SqlValue = (*UUID)(nil)
)
// Reflects
var (
RtTextUnmarshaller = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
RtTextMarshaller = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()
)
// Interfaces
type (
DefaultSetter interface{ SetDefault() }
CanBeZero interface{ Zero() bool }
Stringer interface{ String() string }
SecurityStringer interface{ SecurityString() string }
)