-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.go
42 lines (35 loc) · 841 Bytes
/
util.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
package generator
import (
"go/types"
"strings"
"unicode"
)
func getBasicTypeName(k types.BasicKind) string {
switch k {
case types.Bool:
return "bool"
case types.Int, types.Int8, types.Int16, types.Int32, types.Int64,
types.Uint, types.Uint8, types.Uint16, types.Uint32, types.Uint64:
return "int"
case types.Float32, types.Float64:
return "double"
case types.String:
return "String"
default:
return "dynamic" // Unsupported type
}
}
func convertEnumKey(key string) string {
if len(key) == 0 {
return ""
}
builder := strings.Builder{}
builder.WriteRune(unicode.ToLower(rune(key[0])))
builder.WriteString(key[1:])
return builder.String()
}
// SplitPackegeStruct - package.structを分割
func SplitPackegeStruct(s string) (string, string) {
idx := strings.LastIndex(s, ".")
return s[:idx], s[idx+1:]
}