watcher

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package watcher is a command line tool inspired by fresh (https://github.com/pilu/fresh) and used for watching .go file changes, and restarting the app in case of an update/delete/add operation. After you installed it, you can run your apps with their default parameters as: watcher -c config -p 7000 -h localhost

Package watcher watches all file changes via fsnotify package and sends update events to builder

Index

Constants

This section is empty.

Variables

View Source
var ErrPathNotSet = errors.New("gopath not set")

ErrPathNotSet GoPath not set error

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	DelveArgs []string `yaml:"delve-args,omitempty"`
	Package   struct {
		Args []string `yaml:"args,omitempty"`
	} `yaml:"package"`
	Watcher struct {
		Run         string `yaml:"run"`
		Watch       string `yaml:"watch"`
		WatchVendor string `yaml:"watch-vendor"`
	} `yaml:"watcher,omitempty"`
}

AppConfig contains the argument information for delve, watcher and main package

func ParseArgs

func ParseArgs(args []string, vinfo VersionInfo) *AppConfig

ParseArgs extracts the application parameters from args and returns Params instance with separated watcher and application parameters

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder composes of both debugger and watcher. Whenever watcher gets notified, builder starts a build process, and forces the debugger to restart

func NewBuilder

func NewBuilder(w *Watcher, r *Debugger) *Builder

NewBuilder constructs the Builder instance

func (*Builder) Build

func (b *Builder) Build(appConfig *AppConfig)

Build listens watch events from Watcher and sends messages to Debugger when new changes are built.

type Debugger added in v1.12.0

type Debugger struct {
	// contains filtered or unexported fields
}

Debugger listens for the change events and depending on that kills the obsolete process, and runs a new one

func NewDebugger added in v1.12.0

func NewDebugger() *Debugger

NewDebugger creates a new Debugger instance and returns its pointer

func (*Debugger) Close added in v1.12.0

func (r *Debugger) Close()

Close closes the current debugger

func (*Debugger) Debug added in v1.12.0

func (r *Debugger) Debug(appConfig *AppConfig)

Debug initializes debugger with given parameters.

func (*Debugger) Wait added in v1.12.0

func (r *Debugger) Wait()

Wait waits until the next msg/changes

type VersionInfo

type VersionInfo struct {
	GoVersion string
	Version   string
	Commit    string
	BuildTime string
}

VersionInfo contains all the information regarding the version

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher watches the file change events from fsnotify and sends update messages. It is also used as a fsnotify.Watcher wrapper

func MustRegisterWatcher

func MustRegisterWatcher(appConfig *AppConfig) *Watcher

MustRegisterWatcher creates a new Watcher and starts listening to given folders

func (*Watcher) Close

func (w *Watcher) Close()

Close closes the fsnotify watcher channel

func (*Watcher) Wait

func (w *Watcher) Wait() <-chan struct{}

Wait waits for the latest messages

func (*Watcher) Watch

func (w *Watcher) Watch()

Watch listens file updates, and sends signal to update channel when .go and .tmpl files are updated

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL