-
Notifications
You must be signed in to change notification settings - Fork 5
/
thrift.go
56 lines (47 loc) · 954 Bytes
/
thrift.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
package lang
import (
"strconv"
"github.com/ixre/gof/db/db"
)
var _ Lang = new(Thrift)
type Thrift struct {
}
func (t Thrift) SqlMapType(typeId int, len int) string {
return t.ParseType(typeId)
}
func (t Thrift) PkgName(pkg string) string {
return t.PkgPath(pkg)
}
func (t Thrift) PkgPath(pkg string) string {
return PkgStyleLikeJava(pkg)
}
func (t Thrift) ParseType(typeId int) string {
return ThriftTypes(typeId)
}
func (t Thrift) DefaultValue(typeId int) string {
panic("not support")
}
var _ Lang = new(Thrift)
func ThriftTypes(typeId int) string {
switch typeId {
case db.TypeString:
return "string"
case db.TypeBoolean:
return "bool"
case db.TypeInt16:
return "i16"
case db.TypeInt32:
return "i32"
case db.TypeInt64:
return "i64"
case db.TypeFloat32:
return "f32"
case db.TypeFloat64:
return "f64"
case db.TypeDecimal:
return "f64"
case db.TypeDateTime:
return "string"
}
return strconv.Itoa(typeId)
}