File tree 4 files changed +68
-1
lines changed 4 files changed +68
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : WASM
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - master
7
+ pull_request :
8
+
9
+ jobs :
10
+ build :
11
+ name : Build
12
+ runs-on : ubuntu-latest
13
+ env :
14
+ GOFLAGS : -mod=readonly
15
+
16
+ steps :
17
+ - name : Set up Go
18
+ uses : actions/setup-go@v2
19
+ with :
20
+ go-version : ' 1.16'
21
+
22
+ - name : Checkout code
23
+ uses : actions/checkout@v2
24
+
25
+ - name : Ensure Viper compiles for WASM
26
+ run : GOOS=js GOARCH=wasm go build .
Original file line number Diff line number Diff line change @@ -344,7 +344,7 @@ func (v *Viper) WatchConfig() {
344
344
initWG := sync.WaitGroup {}
345
345
initWG .Add (1 )
346
346
go func () {
347
- watcher , err := fsnotify . NewWatcher ()
347
+ watcher , err := newWatcher ()
348
348
if err != nil {
349
349
log .Fatal (err )
350
350
}
Original file line number Diff line number Diff line change
1
+ // +build !js
2
+
3
+ package viper
4
+
5
+ import "github.com/fsnotify/fsnotify"
6
+
7
+ type watcher = fsnotify.Watcher
8
+
9
+ func newWatcher () (* watcher , error ) {
10
+ return fsnotify .NewWatcher ()
11
+ }
Original file line number Diff line number Diff line change
1
+ // +build js,wasm
2
+
3
+ package viper
4
+
5
+ import (
6
+ "errors"
7
+
8
+ "github.com/fsnotify/fsnotify"
9
+ )
10
+
11
+ type watcher struct {
12
+ Events chan fsnotify.Event
13
+ Errors chan error
14
+ }
15
+
16
+ func (* watcher ) Close () error {
17
+ return nil
18
+ }
19
+
20
+ func (* watcher ) Add (name string ) error {
21
+ return nil
22
+ }
23
+
24
+ func (* watcher ) Remove (name string ) error {
25
+ return nil
26
+ }
27
+
28
+ func newWatcher () (* watcher , error ) {
29
+ return & watcher {}, errors .New ("fsnotify is not supported on WASM" )
30
+ }
You can’t perform that action at this time.
0 commit comments