github.com/tobgu/qframe@v0.4.0/internal/strings/name.go (about) 1 package strings 2 3 import ( 4 "strings" 5 6 "github.com/tobgu/qframe/qerrors" 7 ) 8 9 func isQuoted(s string) bool { 10 return len(s) > 2 && 11 ((strings.HasPrefix(s, "'") && strings.HasSuffix(s, "'")) || 12 (strings.HasPrefix(s, `"`) && strings.HasSuffix(s, `"`))) 13 } 14 15 func CheckName(name string) error { 16 if len(name) == 0 { 17 return qerrors.New("CheckName", "column name must not be empty") 18 } 19 20 if isQuoted(name) { 21 // Reserved for future use 22 return qerrors.New("CheckName", "column name must not be quoted: %s", name) 23 } 24 25 // Reserved for future use of variables in Eval 26 if strings.HasPrefix(name, "$") { 27 return qerrors.New("CheckName", "column name must not start with $: %s", name) 28 } 29 30 return nil 31 }