-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
36 lines (31 loc) · 910 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
package parser
import (
"strings"
)
// -----------------------------------------------------------------------------
func IsPublic(name string) bool {
if len(name) == 0 || name[0] == '_' {
return false
}
s := string(name[0])
firstLetter := strings.ToLower(s)
return firstLetter != s
}
func IsNativeType(name string) bool {
switch name {
case "bool", "byte", "int", "int8", "int16", "int32", "int64", "uint", "uint8", "uint16", "uint32", "uint64", "string", "float", "float64", "float32", "complex128", "complex64", "uintptr":
return true
}
return false
}
func GetIdentifierParts(qualifiedIdentifier string) (packageName string, identifier string) {
dotIdx := strings.Index(qualifiedIdentifier, ".")
if dotIdx >= 0 {
packageName = qualifiedIdentifier[0:dotIdx]
identifier = qualifiedIdentifier[(dotIdx + 1):]
} else {
packageName = ""
identifier = qualifiedIdentifier
}
return
}