github.com/jaypipes/ghw@v0.21.1/pkg/linuxdmi/dmi_linux.go (about) 1 // Use and distribution licensed under the Apache license version 2. 2 // 3 // See the COPYING file in the root project directory for full text. 4 // 5 6 package linuxdmi 7 8 import ( 9 "os" 10 "path/filepath" 11 "strings" 12 13 "github.com/jaypipes/ghw/pkg/context" 14 "github.com/jaypipes/ghw/pkg/linuxpath" 15 "github.com/jaypipes/ghw/pkg/util" 16 ) 17 18 func Item(ctx *context.Context, value string) string { 19 paths := linuxpath.New(ctx) 20 path := filepath.Join(paths.SysClassDMI, "id", value) 21 22 b, err := os.ReadFile(path) 23 if err != nil { 24 ctx.Warn("Unable to read %s: %s\n", value, err) 25 return util.UNKNOWN 26 } 27 28 return strings.TrimSpace(string(b)) 29 }