-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_string.go
57 lines (49 loc) · 1.04 KB
/
cmd_string.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
package pot
/*
StringCmd
@Description: result string cmd
*/
type StringCmd struct {
baseCmd
}
// newStringCmd
func newStringCmd(key string) *StringCmd {
return &StringCmd{
baseCmd: baseCmd{
key: key,
},
}
}
// Val return original value
func (cmd *StringCmd) Val() interface{} {
return cmd.val
}
// Result return string value and error
func (cmd *StringCmd) Result() (string, error) {
return cmd.String(), cmd.err
}
// Int64 return int64 value and error
func (cmd *StringCmd) Int64() (int64, error) {
if cmd.err != nil {
return 0, cmd.err
}
return valConvertInt64(cmd.val), nil
}
// Uint64 return Uint64 value and error
func (cmd *StringCmd) Uint64() (uint64, error) {
if cmd.err != nil {
return 0, cmd.err
}
return valConvertUint64(cmd.val), nil
}
// Float64 return Float64 value and error
func (cmd *StringCmd) Float64() (float64, error) {
if cmd.err != nil {
return 0, cmd.err
}
return valConvertFloat64(cmd.val), nil
}
// String only return String
func (cmd *StringCmd) String() string {
return valConvertString(cmd.val)
}