From 6223594b03149e22a55c6563255d84aaf95c16fb Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Tue, 20 Feb 2024 15:46:44 -0800 Subject: [PATCH] fix: add shims for GOARCH=wasm with GOOS=js and GOOS=wasip1 Fixes build errors: GOOS=js GOARCH=wasm go build GOOS=wasip1 GOARCH=wasm go build Signed-off-by: Christian Stewart --- enumerator/usb_js.go | 11 +++++++++++ enumerator/usb_wasm.go | 14 ++++++++++++++ enumerator_js.go | 12 ++++++++++++ enumerator_wasm.go | 12 ++++++++++++ serial_js.go | 12 ++++++++++++ serial_wasm.go | 12 ++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 enumerator/usb_js.go create mode 100644 enumerator/usb_wasm.go create mode 100644 enumerator_js.go create mode 100644 enumerator_wasm.go create mode 100644 serial_js.go create mode 100644 serial_wasm.go diff --git a/enumerator/usb_js.go b/enumerator/usb_js.go new file mode 100644 index 0000000..3f3b22f --- /dev/null +++ b/enumerator/usb_js.go @@ -0,0 +1,11 @@ +// +// Copyright 2014-2024 Cristian Maglie. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +// + +package enumerator + +func nativeGetDetailedPortsList() ([]*PortDetails, error) { + return nil, &PortEnumerationError{} +} diff --git a/enumerator/usb_wasm.go b/enumerator/usb_wasm.go new file mode 100644 index 0000000..24d79ff --- /dev/null +++ b/enumerator/usb_wasm.go @@ -0,0 +1,14 @@ +// +// Copyright 2014-2024 Cristian Maglie. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +// + +//go:build wasip1 +// +build wasip1 + +package enumerator + +func nativeGetDetailedPortsList() ([]*PortDetails, error) { + return nil, &PortEnumerationError{} +} diff --git a/enumerator_js.go b/enumerator_js.go new file mode 100644 index 0000000..9fa0441 --- /dev/null +++ b/enumerator_js.go @@ -0,0 +1,12 @@ +//go:build js +// +build js + +package serial + +import ( + "errors" +) + +func nativeGetPortsList() ([]string, error) { + return nil, errors.New("nativeGetPortsList is not supported on GOOS=js") +} diff --git a/enumerator_wasm.go b/enumerator_wasm.go new file mode 100644 index 0000000..560ba1b --- /dev/null +++ b/enumerator_wasm.go @@ -0,0 +1,12 @@ +//go:build wasip1 +// +build wasip1 + +package serial + +import ( + "errors" +) + +func nativeGetPortsList() ([]string, error) { + return nil, errors.New("nativeGetPortsList is not supported on GOARCH=wasm") +} diff --git a/serial_js.go b/serial_js.go new file mode 100644 index 0000000..b20987f --- /dev/null +++ b/serial_js.go @@ -0,0 +1,12 @@ +//go:build js +// +build js + +package serial + +import ( + "errors" +) + +func nativeOpen(portName string, mode *Mode) (Port, error) { + return nil, errors.New("nativeOpen is not supported on GOOS=js") +} diff --git a/serial_wasm.go b/serial_wasm.go new file mode 100644 index 0000000..6dd694d --- /dev/null +++ b/serial_wasm.go @@ -0,0 +1,12 @@ +//go:build wasip1 +// +build wasip1 + +package serial + +import ( + "errors" +) + +func nativeOpen(portName string, mode *Mode) (Port, error) { + return nil, errors.New("nativeOpen is not supported on GOARCH=wasm") +}