-
Notifications
You must be signed in to change notification settings - Fork 5
/
protobuf.go
57 lines (47 loc) · 1021 Bytes
/
protobuf.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 lang
import (
"fmt"
"github.com/ixre/gof/db/db"
)
var _ Lang = new(Protobuf)
type Protobuf struct {
}
func (p Protobuf) SqlMapType(typeId int, len int) string {
return p.ParseType(typeId)
}
func (p Protobuf) PkgName(pkg string) string {
return p.PkgPath(pkg)
}
func (p Protobuf) PkgPath(pkg string) string {
return PkgStyleLikeJava(pkg)
}
func (p Protobuf) ParseType(typeId int) string {
return ProtobufTypes(typeId)
}
func (p Protobuf) DefaultValue(typeId int) string {
panic("not support for protobuf")
}
var _ Lang = new(Protobuf)
func ProtobufTypes(typeId int) string {
switch typeId {
case db.TypeBoolean:
return "bool"
case db.TypeFloat32:
return "double"
case db.TypeFloat64:
return "double"
case db.TypeInt16:
return "int32"
case db.TypeInt32:
return "int32"
case db.TypeInt64:
return "int64"
case db.TypeString:
return "string"
case db.TypeDecimal:
return "decimal"
case db.TypeDateTime:
return "string"
}
return fmt.Sprintf("Unknown type id:%d", typeId)
}