From c75c744a518e59f58f7c0349d7f291bdc089a478 Mon Sep 17 00:00:00 2001 From: Steve Ruckdashel Date: Wed, 21 Oct 2020 12:15:11 -0500 Subject: [PATCH 1/2] adding dummy go files for cgo vendoring --- dummy.go | 18 ++++++++++++++++++ hidapi/dummy.go | 7 +++++++ hidapi/hidapi/dummy.go | 7 +++++++ 3 files changed, 32 insertions(+) create mode 100644 dummy.go create mode 100644 hidapi/dummy.go create mode 100644 hidapi/hidapi/dummy.go diff --git a/dummy.go b/dummy.go new file mode 100644 index 0000000..a11ffce --- /dev/null +++ b/dummy.go @@ -0,0 +1,18 @@ +// +build dummy + +// This file is part of a workaround for `go mod vendor` which won't vendor +// C files if there's no Go file in the same directory. +// This would prevent the c/sqlite3.c file to be vendored. +// +// This Go file imports the c directory where there is another dummy.go file which +// is the second part of this workaround. +// +// These two files combined make it so `go mod vendor` behaves correctly. +// +// See this issue for reference: https://github.com/golang/go/issues/26366 + +package sqlite + +import ( + _ "github.com/karalabe/usb/hidapi/c" +) diff --git a/hidapi/dummy.go b/hidapi/dummy.go new file mode 100644 index 0000000..647380f --- /dev/null +++ b/hidapi/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file dummy.go at the root of the module for more information. +package hidapi diff --git a/hidapi/hidapi/dummy.go b/hidapi/hidapi/dummy.go new file mode 100644 index 0000000..93f439e --- /dev/null +++ b/hidapi/hidapi/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file dummy.go at the root of the module for more information. +package c From a44de4807ce6c378893c0d171487995e84e6c24b Mon Sep 17 00:00:00 2001 From: Steve Ruckdashel Date: Wed, 21 Oct 2020 12:33:01 -0500 Subject: [PATCH 2/2] expand vendor dummies everywhere --- dummy.go | 13 ++++++++++--- hidapi/hidapi/dummy.go | 2 +- hidapi/libusb/dummy.go | 7 +++++++ hidapi/mac/dummy.go | 7 +++++++ hidapi/windows/dummy.go | 7 +++++++ libusb/dummy.go | 7 +++++++ libusb/libusb/dummy.go | 7 +++++++ libusb/libusb/os/dummy.go | 7 +++++++ 8 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 hidapi/libusb/dummy.go create mode 100644 hidapi/mac/dummy.go create mode 100644 hidapi/windows/dummy.go create mode 100644 libusb/dummy.go create mode 100644 libusb/libusb/dummy.go create mode 100644 libusb/libusb/os/dummy.go diff --git a/dummy.go b/dummy.go index a11ffce..f6bbdc3 100644 --- a/dummy.go +++ b/dummy.go @@ -2,7 +2,7 @@ // This file is part of a workaround for `go mod vendor` which won't vendor // C files if there's no Go file in the same directory. -// This would prevent the c/sqlite3.c file to be vendored. +// This would prevent the hidapi/hidapi/hidapi.h file to be vendored. // // This Go file imports the c directory where there is another dummy.go file which // is the second part of this workaround. @@ -11,8 +11,15 @@ // // See this issue for reference: https://github.com/golang/go/issues/26366 -package sqlite +package main import ( - _ "github.com/karalabe/usb/hidapi/c" + _ "github.com/karalabe/usb/hidapi" + _ "github.com/karalabe/usb/hidapi/hidapi" + _ "github.com/karalabe/usb/hidapi/libusb" + _ "github.com/karalabe/usb/hidapi/mac" + _ "github.com/karalabe/usb/hidapi/windows" + _ "github.com/karalabe/usb/libusb" + _ "github.com/karalabe/usb/libusb/libusb" + _ "github.com/karalabe/usb/libusb/libusb/os" ) diff --git a/hidapi/hidapi/dummy.go b/hidapi/hidapi/dummy.go index 93f439e..647380f 100644 --- a/hidapi/hidapi/dummy.go +++ b/hidapi/hidapi/dummy.go @@ -4,4 +4,4 @@ // // This Go file is part of a workaround for `go mod vendor`. // Please see the file dummy.go at the root of the module for more information. -package c +package hidapi diff --git a/hidapi/libusb/dummy.go b/hidapi/libusb/dummy.go new file mode 100644 index 0000000..20d44a7 --- /dev/null +++ b/hidapi/libusb/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file dummy.go at the root of the module for more information. +package libusb diff --git a/hidapi/mac/dummy.go b/hidapi/mac/dummy.go new file mode 100644 index 0000000..9e519ac --- /dev/null +++ b/hidapi/mac/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file dummy.go at the root of the module for more information. +package mac diff --git a/hidapi/windows/dummy.go b/hidapi/windows/dummy.go new file mode 100644 index 0000000..d72069e --- /dev/null +++ b/hidapi/windows/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file dummy.go at the root of the module for more information. +package windows diff --git a/libusb/dummy.go b/libusb/dummy.go new file mode 100644 index 0000000..20d44a7 --- /dev/null +++ b/libusb/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file dummy.go at the root of the module for more information. +package libusb diff --git a/libusb/libusb/dummy.go b/libusb/libusb/dummy.go new file mode 100644 index 0000000..20d44a7 --- /dev/null +++ b/libusb/libusb/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file dummy.go at the root of the module for more information. +package libusb diff --git a/libusb/libusb/os/dummy.go b/libusb/libusb/os/dummy.go new file mode 100644 index 0000000..7605504 --- /dev/null +++ b/libusb/libusb/os/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file dummy.go at the root of the module for more information. +package os