-
Notifications
You must be signed in to change notification settings - Fork 0
/
result_value.go
54 lines (44 loc) · 1.55 KB
/
result_value.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
package main
import "go/constant"
type Result struct {
PkgName string // The specified package name of the constant.
TypeName string // The specified type name of the constant.
RepTypeName string // The specified representation of the type name.
Values []Value // The constant definitions
Imports []Import // The import definitions that defined at parsed package
}
type Import struct {
Name string // import name. e.g. "_", "mathrand"
Path string // import path. e.g. "\"math/rand\""
Comment string
Doc string
}
type Value struct {
Name string // The name
Str string // The string representation given by the "go/constant" package.
ExactStr string // The exact string representation given by the "go/constant" package.
Kind constant.Kind // The kind of constant given by the "go/constant" package.
}
func (v Value) String() string {
return v.Str
}
// IsBool returns true if the kind of value is constant.Bool
func (v Value) IsBool() bool {
return v.Kind == constant.Bool
}
// IsString returns true if the kind of value is constant.String
func (v Value) IsString() bool {
return v.Kind == constant.String
}
// IsInt returns true if the kind of value is constant.Int
func (v Value) IsInt() bool {
return v.Kind == constant.Int
}
// IsFloat returns true if the kind of value is constant.Float
func (v Value) IsFloat() bool {
return v.Kind == constant.Float
}
// IsComplex returns true if the kind of value is constant.Complex
func (v Value) IsComplex() bool {
return v.Kind == constant.Complex
}