dmidecode

package module
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 15 Imported by: 0

README

dmidecode

Build and Test codecov Go Report Card Release MIT License

纯Golang实现的dmidecode, 零依赖, 支持Linux, Unix, Windows

功能和命令行的dmidecode工具一样, 使用方式参考: example

开发过程相关小博客: 使用Golang重新实现dmidecode

安装方式

$ go get "github.com/yumaojun03/dmidecode"

使用样例

package main

import (
	"fmt"
	"os"

	"github.com/yumaojun03/dmidecode"
)

func checkError(err error) {
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}

func main() {
	dmi, err := dmidecode.New()
	checkError(err)

	infos, err := dmi.BIOS()
	// 支持以下类型的解析
	// dmi.BaseBoard()
	// dmi.Chassis()
	// dmi.MemoryArray()
	// dmi.MemoryDevice()
	// dmi.Onboard()
	// dmi.PortConnector()
	// dmi.Processor()
	// dmi.ProcessorCache()
	// dmi.Slot()
	// dmi.System()
	checkError(err)

	for i := range infos {
		fmt.Println(infos[i])
	}
}

CLI 使用

$ go run cmd/main.go -d -t [bios, system, baseboard, chassis, onboard, port, processor, memory, slot]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decoder

func New

func New() (*Decoder, error)

New 实例化

func (*Decoder) ALL

func (d *Decoder) ALL() (*InformationSet, error)

ALL decode all

func (*Decoder) BIOS

func (d *Decoder) BIOS() ([]*bios.Information, error)

BIOS 解析bios信息

func (*Decoder) BaseBoard

func (d *Decoder) BaseBoard() ([]*baseboard.Information, error)

BaseBoard 解析baseboard信息

func (*Decoder) Battery

func (d *Decoder) Battery() ([]*battery.Information, error)

Battery 解析battery信息

func (*Decoder) Chassis

func (d *Decoder) Chassis() ([]*chassis.Information, error)

Chassis 解析chassis信息

func (*Decoder) Debug

func (d *Decoder) Debug(on bool)

Debug 开关Debug

func (*Decoder) EntryPoint

func (d *Decoder) EntryPoint() *smbios.EntryPoint

EntryPoint todo

func (*Decoder) MemoryArray

func (d *Decoder) MemoryArray() ([]*memory.PhysicalMemoryArray, error)

MemoryArray 解析memory array信息

func (*Decoder) MemoryDevice

func (d *Decoder) MemoryDevice() ([]*memory.MemoryDevice, error)

MemoryDevice 解析memory device信息

func (*Decoder) OEM

func (d *Decoder) OEM() ([]*oem.OEM, error)

func (*Decoder) Onboard

func (d *Decoder) Onboard() ([]*onboard.Information, error)

Onboard 解析onboard信息

func (*Decoder) OnboardExtended

func (d *Decoder) OnboardExtended() ([]*onboard.ExtendedInformation, error)

OnboardExtended 解析onboard信息

func (*Decoder) PortConnector

func (d *Decoder) PortConnector() ([]*port.Information, error)

PortConnector 解析port connector信息

func (*Decoder) Processor

func (d *Decoder) Processor() ([]*processor.Processor, error)

Processor 解析processor信息

func (*Decoder) ProcessorCache

func (d *Decoder) ProcessorCache() ([]*processor.Cache, error)

ProcessorCache 解析processor cache信息

func (*Decoder) Slot

func (d *Decoder) Slot() ([]*slot.SystemSlot, error)

Slot 解析memory device信息

func (*Decoder) System

func (d *Decoder) System() ([]*system.Information, error)

System 解析system信息

type ErrorSet

type ErrorSet struct {
	// contains filtered or unexported fields
}

ErrorSet errorset

func NewErrorSet

func NewErrorSet() *ErrorSet

NewErrorSet todo

func (*ErrorSet) Error

func (s *ErrorSet) Error() error

HasError todo

type InformationSet

type InformationSet struct {
	// contains filtered or unexported fields
}

InformationSet 集合

func NewInformationSet

func NewInformationSet() *InformationSet

NewInformationSet todo

func (*InformationSet) Print

func (s *InformationSet) Print()

Print 打印所有

Directories

Path Synopsis
parser
oem

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL