Explorar o código

Make kernel detection work without suffix

Guillaume J. Charmes %!s(int64=12) %!d(string=hai) anos
pai
achega
c05c91ca3b
Modificáronse 2 ficheiros con 8 adicións e 0 borrados
  1. 4 0
      getKernelVersion_darwin.go
  2. 4 0
      getKernelVersion_linux.go

+ 4 - 0
getKernelVersion_darwin.go

@@ -1,5 +1,9 @@
 package docker
 
+import (
+	"fmt"
+)
+
 func getKernelVersion() (*KernelVersionInfo, error) {
 	return nil, fmt.Errorf("Kernel version detection is not available on darwin")
 }

+ 4 - 0
getKernelVersion_linux.go

@@ -1,6 +1,7 @@
 package docker
 
 import (
+	"bytes"
 	"strconv"
 	"strings"
 	"syscall"
@@ -26,6 +27,9 @@ func getKernelVersion() (*KernelVersionInfo, error) {
 		i++
 	}
 
+	// Remove the \x00 from the release for Atoi to parse correctly
+	release = release[:bytes.IndexByte(release, 0)]
+
 	tmp := strings.SplitN(string(release), "-", 2)
 	tmp2 := strings.SplitN(tmp[0], ".", 3)