fix: package name regex

This commit is contained in:
Rogee
2024-12-23 11:13:54 +08:00
parent 9cd4dcaeb2
commit 38e1a051c5

View File

@@ -16,7 +16,7 @@ import (
) )
// 验证包名是否合法:支持域名、路径分隔符和常见字符 // 验证包名是否合法:支持域名、路径分隔符和常见字符
var goPackageRegexp = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9-_.]*[a-zA-Z0-9](/[a-zA-Z0-9][a-zA-Z0-9-_.]*[a-zA-Z0-9])*$`) var goPackageRegexp = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9-_.]*[a-zA-Z0-9](/[a-zA-Z0-9][a-zA-Z0-9-_.]*)*$`)
func isValidGoPackageName(name string) bool { func isValidGoPackageName(name string) bool {
return goPackageRegexp.MatchString(name) return goPackageRegexp.MatchString(name)