-
Notifications
You must be signed in to change notification settings - Fork 432
/
converter.go
105 lines (93 loc) · 1.98 KB
/
converter.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package gogoutils
import (
"time"
"github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/duration"
"github.com/golang/protobuf/ptypes/wrappers"
)
func UInt32ProtoToGogo(pr *wrappers.UInt32Value) *types.UInt32Value {
var ret *types.UInt32Value
if pr != nil {
ret = &types.UInt32Value{
Value: pr.GetValue(),
}
}
return ret
}
func UInt32GogoToProto(pr *types.UInt32Value) *wrappers.UInt32Value {
var ret *wrappers.UInt32Value
if pr != nil {
ret = &wrappers.UInt32Value{
Value: pr.GetValue(),
}
}
return ret
}
func UInt64ProtoToGogo(pr *wrappers.UInt64Value) *types.UInt64Value {
var ret *types.UInt64Value
if pr != nil {
ret = &types.UInt64Value{
Value: pr.GetValue(),
}
}
return ret
}
func UInt64GogoToProto(pr *types.UInt64Value) *wrappers.UInt64Value {
var ret *wrappers.UInt64Value
if pr != nil {
ret = &wrappers.UInt64Value{
Value: pr.GetValue(),
}
}
return ret
}
func BoolProtoToGogo(pr *wrappers.BoolValue) *types.BoolValue {
var ret *types.BoolValue
if pr != nil {
ret = &types.BoolValue{
Value: pr.GetValue(),
}
}
return ret
}
func BoolGogoToProto(pr *types.BoolValue) *wrappers.BoolValue {
var ret *wrappers.BoolValue
if pr != nil {
ret = &wrappers.BoolValue{
Value: pr.GetValue(),
}
}
return ret
}
func DurationProtoToGogo(pr *duration.Duration) *types.Duration {
var ret *types.Duration
if pr != nil {
ret = &types.Duration{
Seconds: pr.GetSeconds(),
Nanos: pr.GetNanos(),
}
}
return ret
}
func DurationGogoToProto(pr *types.Duration) *duration.Duration {
var ret *duration.Duration
if pr != nil {
ret = &duration.Duration{
Seconds: pr.GetSeconds(),
Nanos: pr.GetNanos(),
}
}
return ret
}
func DurationStdToProto(pr *time.Duration) *duration.Duration {
var ret *duration.Duration
if pr != nil {
ret = ptypes.DurationProto(*pr)
}
return ret
}
func DurationProtoToStd(pr *duration.Duration) *time.Duration {
dur, _ := ptypes.Duration(pr)
return &dur
}