-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make sure Viper compiles on WASM
fsnotify is not available on WASM, so config watching is not going to work. Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
- Loading branch information
1 parent
727a41c
commit 36be6bf
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: WASM | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
env: | ||
GOFLAGS: -mod=readonly | ||
|
||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.16' | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Ensure Viper compiles for WASM | ||
run: GOOS=js GOARCH=wasm go build . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// +build !js | ||
|
||
package viper | ||
|
||
import "github.com/fsnotify/fsnotify" | ||
|
||
type watcher = fsnotify.Watcher | ||
|
||
func newWatcher() (*watcher, error) { | ||
return fsnotify.NewWatcher() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// +build js,wasm | ||
|
||
package viper | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/fsnotify/fsnotify" | ||
) | ||
|
||
type watcher struct { | ||
Events chan fsnotify.Event | ||
Errors chan error | ||
} | ||
|
||
func (*watcher) Close() error { | ||
return nil | ||
} | ||
|
||
func (*watcher) Add(name string) error { | ||
return nil | ||
} | ||
|
||
func (*watcher) Remove(name string) error { | ||
return nil | ||
} | ||
|
||
func newWatcher() (*watcher, error) { | ||
return &watcher{}, errors.New("fsnotify is not supported on WASM") | ||
} |