Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make Viper compile on platforms unsupported by fsnotify #1457

Merged
merged 5 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ on:
pull_request:

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: js
goarch: wasm
- goos: aix
goarch: ppc64

steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Checkout code
uses: actions/checkout@v3

- name: Build
run: go build .
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}

test:
name: Test
runs-on: ${{ matrix.os }}
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/wasm.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions watch.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !js
// +build !js
//go:build darwin || dragonfly || freebsd || openbsd || linux || netbsd || solaris || windows
// +build darwin dragonfly freebsd openbsd linux netbsd solaris windows

package viper

Expand Down
14 changes: 8 additions & 6 deletions watch_wasm.go → watch_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// +build js,wasm
//go:build !darwin && !dragonfly && !freebsd && !openbsd && !linux && !netbsd && !solaris && !windows
// +build !darwin,!dragonfly,!freebsd,!openbsd,!linux,!netbsd,!solaris,!windows

package viper

import (
"errors"
"fmt"
"runtime"

"github.com/fsnotify/fsnotify"
)

func newWatcher() (*watcher, error) {
return &watcher{}, fmt.Errorf("fsnotify not supported on %s", runtime.GOOS)
}

type watcher struct {
Events chan fsnotify.Event
Errors chan error
Expand All @@ -24,7 +30,3 @@ func (*watcher) Add(name string) error {
func (*watcher) Remove(name string) error {
return nil
}

func newWatcher() (*watcher, error) {
return &watcher{}, errors.New("fsnotify is not supported on WASM")
}