mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Fix goMinorVersion on non-final Go releases
This should work for alpha/beta/rc releases.
This commit is contained in:
parent
b2dcd53e3c
commit
c7975b48b6
2 changed files with 13 additions and 4 deletions
|
@ -15,7 +15,7 @@ package hugo
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"io"
|
||||
|
||||
"runtime"
|
||||
"strings"
|
||||
|
@ -245,7 +245,15 @@ func goMinorVersion(version string) int {
|
|||
if strings.HasPrefix(version, "devel") {
|
||||
return 9999 // magic
|
||||
}
|
||||
i, _ := strconv.Atoi(strings.Split(version, ".")[1])
|
||||
return i
|
||||
|
||||
var major, minor int
|
||||
var trailing string
|
||||
n, err := fmt.Sscanf(version, "go%d.%d%s", &major, &minor, &trailing)
|
||||
if n == 2 && err == io.EOF {
|
||||
// Means there were no trailing characters (i.e., not an alpha/beta)
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return minor
|
||||
}
|
||||
|
|
|
@ -84,5 +84,6 @@ func TestParseHugoVersion(t *testing.T) {
|
|||
func TestGoMinorVersion(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
c.Assert(goMinorVersion("go1.12.5"), qt.Equals, 12)
|
||||
c.Assert(goMinorVersion("go1.14rc1"), qt.Equals, 14)
|
||||
c.Assert(GoMinorVersion() >= 11, qt.Equals, true)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue