-
Notifications
You must be signed in to change notification settings - Fork 5
/
types.go
50 lines (38 loc) · 1.02 KB
/
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
48
49
50
package rpcx
import (
"fmt"
"github.com/meshplus/bitxhub-model/pb"
)
func Int32(i int32) *pb.Arg {
return generateArg(pb.Arg_I32, []byte(fmt.Sprintf("%d", i)))
}
func Int64(i int64) *pb.Arg {
return generateArg(pb.Arg_I64, []byte(fmt.Sprintf("%d", i)))
}
func Uint32(i uint32) *pb.Arg {
return generateArg(pb.Arg_U32, []byte(fmt.Sprintf("%d", i)))
}
func Uint64(i uint64) *pb.Arg {
return generateArg(pb.Arg_U64, []byte(fmt.Sprintf("%d", i)))
}
func Float32(f float32) *pb.Arg {
return generateArg(pb.Arg_F32, []byte(fmt.Sprintf("%g", f)))
}
func Float64(f float64) *pb.Arg {
return generateArg(pb.Arg_F64, []byte(fmt.Sprintf("%g", f)))
}
func String(content string) *pb.Arg {
return generateArg(pb.Arg_String, []byte(content))
}
func Bytes(content []byte) *pb.Arg {
return generateArg(pb.Arg_Bytes, content)
}
func Bool(b bool) *pb.Arg {
return generateArg(pb.Arg_Bool, []byte(fmt.Sprintf("%v", b)))
}
func generateArg(typ pb.Arg_Type, content []byte) *pb.Arg {
return &pb.Arg{
Type: typ,
Value: content,
}
}