Draft for Multi-Language Modelfile Creation
This commit is contained in:
parent
646371f56d
commit
73fb9ea36e
@ -10,6 +10,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Errors
|
// Errors
|
||||||
@ -318,14 +319,14 @@ func isValidPart(kind partKind, s string) bool {
|
|||||||
if !isValidLen(kind, s) {
|
if !isValidLen(kind, s) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for i := range s {
|
for i, c := range s {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
if !isAlphanumericOrUnderscore(s[i]) {
|
if !isLetterorUnderscore(c) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch s[i] {
|
switch c {
|
||||||
case '_', '-':
|
case '_', '-':
|
||||||
case '.':
|
case '.':
|
||||||
if kind == kindNamespace {
|
if kind == kindNamespace {
|
||||||
@ -336,7 +337,7 @@ func isValidPart(kind partKind, s string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if !isAlphanumericOrUnderscore(s[i]) {
|
if !isLetterorUnderscore(c) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,8 +345,8 @@ func isValidPart(kind partKind, s string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func isAlphanumericOrUnderscore(c byte) bool {
|
func isLetterorUnderscore(c rune) bool {
|
||||||
return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '_'
|
return unicode.IsLetter(c) || c == '_'
|
||||||
}
|
}
|
||||||
|
|
||||||
func cutLast(s, sep string) (before, after string, ok bool) {
|
func cutLast(s, sep string) (before, after string, ok bool) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user