github.com/haraldrudell/parl@v0.4.176/punix/os-version_test.go (about) 1 /* 2 © 2023–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 package punix 7 8 import ( 9 "fmt" 10 "runtime" 11 "testing" 12 13 "github.com/haraldrudell/parl/perrors" 14 ) 15 16 // go test -run=^TestOsVersion$ -v ./punix 17 // 18 // - goversion: go1.20.1 19 // - osversion: macOS 13.2.1 20 // - osversion: Linux 5.15.0-56-generic 21 func TestOsVersion(t *testing.T) { 22 fmt.Println("goversion: " + runtime.Version()) 23 var version string 24 var hasVersion bool 25 var err error 26 if version, hasVersion, err = OsVersion(); err != nil { 27 t.Errorf("OsVersion failed: %s", perrors.Short(err)) 28 } else if hasVersion { 29 fmt.Println("osversion: " + version) 30 } 31 }