Files
cli
cmd
pkg
scripts
tests
vendor
coopcloud.tech
dario.cat
git.coopcloud.tech
github.com
go.opentelemetry.io
golang.org
x
crypto
exp
net
sync
sys
cpu
asm_aix_ppc64.s
asm_darwin_x86_gc.s
byteorder.go
cpu.go
cpu_aix.go
cpu_arm.go
cpu_arm64.go
cpu_arm64.s
cpu_darwin_x86.go
cpu_gc_arm64.go
cpu_gc_s390x.go
cpu_gc_x86.go
cpu_gc_x86.s
cpu_gccgo_arm64.go
cpu_gccgo_s390x.go
cpu_gccgo_x86.c
cpu_gccgo_x86.go
cpu_linux.go
cpu_linux_arm.go
cpu_linux_arm64.go
cpu_linux_mips64x.go
cpu_linux_noinit.go
cpu_linux_ppc64x.go
cpu_linux_riscv64.go
cpu_linux_s390x.go
cpu_loong64.go
cpu_mips64x.go
cpu_mipsx.go
cpu_netbsd_arm64.go
cpu_openbsd_arm64.go
cpu_openbsd_arm64.s
cpu_other_arm.go
cpu_other_arm64.go
cpu_other_mips64x.go
cpu_other_ppc64x.go
cpu_other_riscv64.go
cpu_other_x86.go
cpu_ppc64x.go
cpu_riscv64.go
cpu_s390x.go
cpu_s390x.s
cpu_wasm.go
cpu_x86.go
cpu_zos.go
cpu_zos_s390x.go
endian_big.go
endian_little.go
hwcap_linux.go
parse.go
proc_cpuinfo_linux.go
runtime_auxv.go
runtime_auxv_go121.go
syscall_aix_gccgo.go
syscall_aix_ppc64_gc.go
syscall_darwin_x86_gc.go
execabs
plan9
unix
windows
LICENSE
PATENTS
term
text
time
google.golang.org
gopkg.in
gotest.tools
modules.txt
.dockerignore
.drone.yml
.envrc.sample
.gitignore
.goreleaser.yml
AUTHORS.md
Dockerfile
LICENSE
Makefile
README.md
go.mod
go.sum
renovate.json
abra/vendor/golang.org/x/sys/cpu/parse.go
2024-08-04 11:06:58 +02:00

44 lines
1.0 KiB
Go

// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cpu
import "strconv"
// parseRelease parses a dot-separated version number. It follows the semver
// syntax, but allows the minor and patch versions to be elided.
//
// This is a copy of the Go runtime's parseRelease from
// https://golang.org/cl/209597.
func parseRelease(rel string) (major, minor, patch int, ok bool) {
// Strip anything after a dash or plus.
for i := 0; i < len(rel); i++ {
if rel[i] == '-' || rel[i] == '+' {
rel = rel[:i]
break
}
}
next := func() (int, bool) {
for i := 0; i < len(rel); i++ {
if rel[i] == '.' {
ver, err := strconv.Atoi(rel[:i])
rel = rel[i+1:]
return ver, err == nil
}
}
ver, err := strconv.Atoi(rel)
rel = ""
return ver, err == nil
}
if major, ok = next(); !ok || rel == "" {
return
}
if minor, ok = next(); !ok || rel == "" {
return
}
patch, ok = next()
return
}