First cut
This commit is contained in:
41
usbid/load.go
Normal file
41
usbid/load.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package usbid
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"log"
|
||||
|
||||
"github.com/kylelemons/gousb/usb"
|
||||
)
|
||||
|
||||
const (
|
||||
LinuxUsbDotOrg = "http://www.linux-usb.org/usb.ids"
|
||||
)
|
||||
|
||||
var Vendors map[usb.ID]*Vendor
|
||||
|
||||
func LoadFromURL(url string) error {
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
ids, err := ParseIDs(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Vendors = ids
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
ids, err := ParseIDs(strings.NewReader(usbIdListData))
|
||||
if err != nil {
|
||||
log.Printf("usbid: failed to parse: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
Vendors = ids
|
||||
}
|
Reference in New Issue
Block a user