gitlab.com/apertussolutions/u-root@v7.0.0+incompatible/pkg/smbios/header.go (about) 1 // Copyright 2016-2019 the u-root 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 package smbios 6 7 import ( 8 "bytes" 9 "encoding/binary" 10 "fmt" 11 ) 12 13 // Header is the header common to all table types. 14 type Header struct { 15 Type TableType 16 Length uint8 17 Handle uint16 18 } 19 20 // Parse parses the header from the binary data. 21 func (h *Header) Parse(data []byte) error { 22 return binary.Read(bytes.NewReader(data), binary.LittleEndian, h) 23 } 24 25 // String returns string representation os the header. 26 func (h *Header) String() string { 27 return fmt.Sprintf( 28 "Handle 0x%04X, DMI type %d, %d bytes\n%s", 29 h.Handle, h.Type, h.Length, h.Type) 30 }