当前位置:网站首页>You have a string of code, but do not support the lower version of go; Judge the go version number, you deserve it!

You have a string of code, but do not support the lower version of go; Judge the go version number, you deserve it!

2022-06-23 08:17:00 Deng_ Xian_ Sheng

I don't say much nonsense

Show You Code!

//  copyright  2022  article   author .
//  The use of this source code is restricted by  CC 4.0 BY-SA  Constraints of style license , The license can be found in the article header .
	version := runtime.Version()
	reg := regexp.MustCompile(`(\d.*\.\d.*\.\d.*)`)
	if reg == nil {
    
		log.Panicln(" Regular expression parsing failed ")
	}
	versionStr := reg.FindAllStringSubmatch(version, -1)
	versionSlice := strings.Split(versionStr[0][1], ".")
	var intSlice []int
	for _, v := range versionSlice {
    
		atoi, err := strconv.Atoi(v)
		if err != nil {
    
			log.Panicln("strconv  error ")
		}
		intSlice = append(intSlice, atoi)
	}
	if !(intSlice[0] >= 1 && intSlice[1] >= 18) {
    
		return
	}
	fmt.Println("happy")
原网站

版权声明
本文为[Deng_ Xian_ Sheng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230748481213.html