/
types.go
73 lines (66 loc) · 1.62 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package protodescriptorset
import (
"encoding/json"
"github.com/curioswitch/go-docs-handler/specification"
)
type protoTypeSignature int
const (
protoTypeSignatureBool protoTypeSignature = iota
protoTypeSignatureInt32
protoTypeSignatureInt64
protoTypeSignatureUint32
protoTypeSignatureUint64
protoTypeSignatureSint32
protoTypeSignatureSint64
protoTypeSignatureFixed32
protoTypeSignatureFixed64
protoTypeSignatureSfixed32
protoTypeSignatureSfixed64
protoTypeSignatureFloat
protoTypeSignatureDouble
protoTypeSignatureString
protoTypeSignatureBytes
protoTypeSignatureUnknown
)
func (p protoTypeSignature) Type() specification.TypeSignatureType {
return specification.TypeSignatureTypeBase
}
func (p protoTypeSignature) Signature() string {
switch p {
case protoTypeSignatureBool:
return "bool"
case protoTypeSignatureInt32:
return "int32"
case protoTypeSignatureInt64:
return "int64"
case protoTypeSignatureUint32:
return "uint32"
case protoTypeSignatureUint64:
return "uint64"
case protoTypeSignatureSint32:
return "sint32"
case protoTypeSignatureSint64:
return "sint64"
case protoTypeSignatureFixed32:
return "fixed32"
case protoTypeSignatureFixed64:
return "fixed64"
case protoTypeSignatureSfixed32:
return "sfixed32"
case protoTypeSignatureSfixed64:
return "sfixed64"
case protoTypeSignatureFloat:
return "float"
case protoTypeSignatureDouble:
return "double"
case protoTypeSignatureString:
return "string"
case protoTypeSignatureBytes:
return "bytes"
default:
return "unknown"
}
}
func (p protoTypeSignature) MarshalJSON() ([]byte, error) {
return json.Marshal(p.Signature())
}