From 9426c52f6696b9f142cc6d5876d1886790874140 Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Mon, 9 Nov 2020 19:45:02 -0500 Subject: [PATCH 1/3] Fix build on Plan 9 This fixes build for programs that import fsnotify but fsnotify is not absolutely necessary for the program to be useful. --- fen.go | 2 +- kqueue.go | 2 +- plan9.go | 35 +++++++++++++++++++++++++++++++++++ windows.go | 2 +- 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 plan9.go diff --git a/fen.go b/fen.go index b3ac3d8f..3836bf70 100644 --- a/fen.go +++ b/fen.go @@ -32,7 +32,7 @@ func (w *Watcher) Add(name string) error { return nil } -// Remove stops watching the the named file or directory (non-recursively). +// Remove stops watching the named file or directory (non-recursively). func (w *Watcher) Remove(name string) error { return nil } diff --git a/kqueue.go b/kqueue.go index 87c25b06..a93332fc 100644 --- a/kqueue.go +++ b/kqueue.go @@ -102,7 +102,7 @@ func (w *Watcher) Add(name string) error { return err } -// Remove stops watching the the named file or directory (non-recursively). +// Remove stops watching the named file or directory (non-recursively). func (w *Watcher) Remove(name string) error { name = filepath.Clean(name) w.mu.Lock() diff --git a/plan9.go b/plan9.go new file mode 100644 index 00000000..372f948e --- /dev/null +++ b/plan9.go @@ -0,0 +1,35 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build plan9 + +package fsnotify + +import "syscall" + +// Watcher watches a set of files, delivering events to a channel. +type Watcher struct { + Events chan Event + Errors chan error +} + +// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. +func NewWatcher() (*Watcher, error) { + return nil, syscall.EPLAN9 +} + +// Close removes all watches and closes the events channel. +func (w *Watcher) Close() error { + return syscall.EPLAN9 +} + +// Add starts watching the named file or directory (non-recursively). +func (w *Watcher) Add(name string) error { + return syscall.EPLAN9 +} + +// Remove stops watching the named file or directory (non-recursively). +func (w *Watcher) Remove(name string) error { + return syscall.EPLAN9 +} diff --git a/windows.go b/windows.go index ecae0ce1..d3816609 100644 --- a/windows.go +++ b/windows.go @@ -92,7 +92,7 @@ func (w *Watcher) Add(name string) error { return <-in.reply } -// Remove stops watching the the named file or directory (non-recursively). +// Remove stops watching the named file or directory (non-recursively). func (w *Watcher) Remove(name string) error { in := &input{ op: opRemoveWatch, From 527b9c86579e47aa37b582b367f52d9e4fa127fa Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Thu, 21 Jul 2022 13:51:26 +0200 Subject: [PATCH 2/3] Test it builds in the CI too --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b595c7e9..e1fd549e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,7 @@ jobs: - freebsd - ios - linux + - plan9 - windows goarch: - amd64 From a064ea85802e9173bf8e00f17633658b0c0f6a3e Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Thu, 21 Jul 2022 13:55:26 +0200 Subject: [PATCH 3/3] Fix build constraint --- plan9.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plan9.go b/plan9.go index 372f948e..0d9a87b3 100644 --- a/plan9.go +++ b/plan9.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build plan9 // +build plan9 package fsnotify