Skip to content

Commit

Permalink
fix: add shims for GOARCH=wasm with GOOS=js and GOOS=wasip1
Browse files Browse the repository at this point in the history
Fixes build errors:

GOOS=js GOARCH=wasm go build
GOOS=wasip1 GOARCH=wasm go build

Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed Feb 20, 2024
1 parent 259bdeb commit 6223594
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
11 changes: 11 additions & 0 deletions enumerator/usb_js.go
Original file line number Diff line number Diff line change
@@ -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{}
}
14 changes: 14 additions & 0 deletions enumerator/usb_wasm.go
Original file line number Diff line number Diff line change
@@ -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{}
}
12 changes: 12 additions & 0 deletions enumerator_js.go
Original file line number Diff line number Diff line change
@@ -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")
}
12 changes: 12 additions & 0 deletions enumerator_wasm.go
Original file line number Diff line number Diff line change
@@ -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")
}
12 changes: 12 additions & 0 deletions serial_js.go
Original file line number Diff line number Diff line change
@@ -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")
}
12 changes: 12 additions & 0 deletions serial_wasm.go
Original file line number Diff line number Diff line change
@@ -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")
}

0 comments on commit 6223594

Please sign in to comment.