windisk

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2021 License: MIT Imports: 3 Imported by: 0

README

Windisk

Windisk is a tiny library to retrieve disk info such as serial number, product id, vendor id, etc... It uses winapi so no need to install external dependencies.

Usage

windisk.GetDiskInfo() returns DeviceInfo struct which is;

type DeviceInfo struct {
	SerialNumber     string
	IsRemovableMedia bool
	VendorID         string
	ProductID        string
	ProductRevision  string
	BusType          bustype.BusType
}
package main

import (
	"fmt"
	"log"
	"os"
	"os/signal"
	"path/filepath"

	"github.com/sigkilled/windisk"
)

func main() {
	volumeName := filepath.VolumeName(os.Args[0])
	di, err := windisk.GetDiskInfo("\\\\.\\" + volumeName)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Printf("%+v\n", di)
	c := make(chan os.Signal)
	signal.Notify(c, os.Interrupt)
	<-c
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceInfo

type DeviceInfo struct {
	SerialNumber     string
	IsRemovableMedia bool
	VendorID         string
	ProductID        string
	ProductRevision  string
	BusType          bustype.BusType
}

func GetDiskInfo

func GetDiskInfo(diskpath string) (*DeviceInfo, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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