github.com/bir3/gocompiler@v0.9.2202/src/cmd/internal/osinfo/os_unix.go (about)

     1  // Copyright 2022 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build unix
     6  
     7  package osinfo
     8  
     9  import "github.com/bir3/gocompiler/src/xvendor/golang.org/x/sys/unix"
    10  
    11  // Version returns the OS version name/number.
    12  func Version() (string, error) {
    13  	var uts unix.Utsname
    14  	if err := unix.Uname(&uts); err != nil {
    15  		return "", err
    16  	}
    17  
    18  	sysname := unix.ByteSliceToString(uts.Sysname[:])
    19  	release := unix.ByteSliceToString(uts.Release[:])
    20  	version := unix.ByteSliceToString(uts.Version[:])
    21  	machine := unix.ByteSliceToString(uts.Machine[:])
    22  
    23  	return sysname + " " + release + " " + version + " " + machine, nil
    24  }