appreload

package
v0.0.0-...-a1933d6 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package appreload allows to detect changes in the source code for a Go application and rebuild the executable. In case of success it can kill the previous running version, and launch the newly created executable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppUpdater

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

AppUpdater keeps tracks of changes in an app, and updated the files automatically. It also rebuilds and relaunches the app in case source files changed.

func NewAppUpdater

func NewAppUpdater(conf *AppUpdaterConf, ins *obs.Insighter) *AppUpdater

NewAppUpdater creates a new AppUpdater struct to keep track of changes

func (*AppUpdater) Launch

func (a *AppUpdater) Launch()

Launch starts watching directories for changes, taking action for those file extensions that are listed in the build and resources list in the AppUpdaterConf

func (*AppUpdater) RebuildAndRelaunch

func (a *AppUpdater) RebuildAndRelaunch()

RebuildAndRelaunch tries to rebuild an executable, and if succesful kills old one to launch the new one.

func (*AppUpdater) Shutdown

func (a *AppUpdater) Shutdown()

Shutdown stops watching for file changes

func (*AppUpdater) UpdateResource

func (a *AppUpdater) UpdateResource(e *watcher.Event)

UpdateResource collects a new / updated resource file and puts in the bundle directory.

type AppUpdaterConf

type AppUpdaterConf struct {
	ExecDir       string
	PkgsDirs      []string
	BuildFileExts []string
	ResFileExts   []string
	BundleDir     string
}

AppUpdaterConf has the config vars to set up an AppUpdater instance:

  • ExecDir: the main sources directory for the executable (is also used to generate the temp binary file name)
  • PkgsDirs: the list of directories to observe for changes
  • BuildFileExts: file extensions that should trigger a new binary build
  • ResFilesExts: file extensions that should trigger an update of the resource files

Jump to

Keyboard shortcuts

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