1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-07-26 11:44:22 -04:00

update protogen to strip unused part

This commit is contained in:
Shelikhoo 2025-02-02 15:38:26 +00:00
parent 3ee9045697
commit ab53388d41
No known key found for this signature in database
GPG Key ID: 4C9764E9FE80A3DC

View File

@ -108,9 +108,9 @@ func getProjectProtocVersion(url string) (string, error) {
if err != nil {
return "", fmt.Errorf("can not read from body")
}
versionRegexp := regexp.MustCompile(`\/\/\s*protoc\s*v(\d+\.\d+\.\d+)`)
versionRegexp := regexp.MustCompile(`\/\/\s*protoc\s*v(\d+\.(\d+\.\d+))`)
matched := versionRegexp.FindStringSubmatch(string(body))
return matched[1], nil
return matched[2], nil
}
func getInstalledProtocVersion(protocPath string) (string, error) {
@ -126,10 +126,6 @@ func getInstalledProtocVersion(protocPath string) (string, error) {
if len(matched) == 0 {
return "", errors.New("can not parse protoc version")
}
if len(matched) == 2 {
installedVersion += "4." // in contrast to getProjectProtocVersion()
}
installedVersion += matched[1]
fmt.Println("Using protoc version: " + installedVersion)
return installedVersion, nil
@ -139,9 +135,6 @@ func parseVersion(s string, width int) int64 {
strList := strings.Split(s, ".")
format := fmt.Sprintf("%%s%%0%ds", width)
v := ""
if len(strList) == 2 {
strList = append([]string{"4"}, strList...)
}
for _, value := range strList {
v = fmt.Sprintf(format, v, value)
}