fix(protoc): only use regular version

Signed-off-by: storyicon <yuanchao@bilibili.com>
This commit is contained in:
storyicon 2021-08-28 19:14:45 +08:00
parent 8bdd192681
commit ef9cf8a802
No known key found for this signature in database
GPG key ID: 245915D985F966CF
3 changed files with 66 additions and 3 deletions

View file

@ -115,7 +115,17 @@ func GetExitCode(err error) int {
return 1
}
var regexpEnvironmentVar = regexp.MustCompile(`\$[A-Za-z_]+`)
var (
regexpEnvironmentVar = regexp.MustCompile(`\$[A-Za-z_]+`)
regexpRegularVersion = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+$`)
)
// IsRegularVersion is used to determine whether the version number is a regular version number
// Regular: va.b.c, and a, b, c are all numbers
func IsRegularVersion(s string) bool {
return regexpRegularVersion.MatchString(s)
}
// RenderWithEnv is used to render string with env
func RenderWithEnv(s string, ext map[string]string) string {