// Copyright The OpenTelemetry Authors// SPDX-License-Identifier: Apache-2.0//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zospackage resource // import "go.opentelemetry.io/otel/sdk/resource"import ()type unameProvider func(buf *unix.Utsname) (err error)var defaultUnameProvider unameProvider = unix.Unamevar currentUnameProvider = defaultUnameProviderfunc setDefaultUnameProvider() {setUnameProvider(defaultUnameProvider)}func setUnameProvider( unameProvider) {currentUnameProvider = }// platformOSDescription returns a human readable OS version information string.// The final string combines OS release information (where available) and the// result of the `uname` system call.func platformOSDescription() (string, error) { , := uname()if != nil {return"", } := osRelease()if != "" {returnfmt.Sprintf("%s (%s)", , ), nil }return , nil}// uname issues a uname(2) system call (or equivalent on systems which doesn't// have one) and formats the output in a single string, similar to the output// of the `uname` commandline program. The final string resembles the one// obtained with a call to `uname -snrvm`.func uname() (string, error) {varunix.Utsname := currentUnameProvider(&)if != nil {return"", }returnfmt.Sprintf("%s %s %s %s %s",unix.ByteSliceToString(.Sysname[:]),unix.ByteSliceToString(.Nodename[:]),unix.ByteSliceToString(.Release[:]),unix.ByteSliceToString(.Version[:]),unix.ByteSliceToString(.Machine[:]), ), nil}// getFirstAvailableFile returns an *os.File of the first available// file from a list of candidate file paths.func getFirstAvailableFile( []string) (*os.File, error) {for , := range { , := os.Open()if == nil {return , nil } }returnnil, fmt.Errorf("no candidate file available: %v", )}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.