gowatch

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	AppName: "app",
	Output:  "./",
	Watch: WatchCfg{
		FileExt: []string{".go"},
		Paths:   []string{},
		Vendor:  false,
		Exclude: []string{},
	},
	Build: BuildCfg{
		Delay: 5000,
		Args:  []string{},
	},
	Run: RunCfg{
		AutoRun: true,
		Args:    []string{},
		Envs:    []string{},
	},
}

默认值

Functions

func Exists

func Exists(path string) bool

判断所给路径文件/文件夹是否存在

func IsDir

func IsDir(path string) bool

判断所给路径是否为文件夹

func IsFile

func IsFile(path string) bool

判断所给路径是否为文件

func NewDebounced

func NewDebounced(after time.Duration) func(f func())

New returns a debounced function that takes another functions as its argument. This function will be called when the debounced function stops being called for the given duration. The debounced function can be invoked with different functions, if needed, the last one will win.

func PrintVersion

func PrintVersion()

打印当前版本

Types

type BuildCfg

type BuildCfg struct {
	// 构建延时(单位:毫秒),默认是'5000ms'
	Delay int64 `yaml:"delay"`
	// 构建时的额外参数
	Args []string `yaml:"args"`
	// 需要编译的包或文件,多个使用','分隔
	Pkg string `yaml:"pkg"`
	// 在go build 时期接收的-tags参数
	Tags string `yaml:"tags"`
}

type Config

type Config struct {
	// 执行的app名字,默认是'app.exe'
	AppName string `yaml:"app-name"`
	// 指定output执行的程序路径,默认是'./'
	Output string `yaml:"output"`
	// watch相关参数
	Watch WatchCfg
	// build相关参数
	Build BuildCfg
	// run相关参数
	Run RunCfg
}

func ParseConfig

func ParseConfig(filePath string) *Config

解析配置文件

func (*Config) UnmarshalYAML

func (s *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

Yml解析默认值

type RunCfg

type RunCfg struct {
	// build完成后是否自动运行,默认是'true'
	AutoRun bool `yaml:"auto-run"`
	// 执行时的额外参数
	Args []string `yaml:"args"`
	// 执行时追加的环境变量
	Envs []string `yaml:"envs"`
}

type WatchCfg

type WatchCfg struct {
	// 需要追加监听的文件后缀名字,默认是'.go',
	FileExt []string `yaml:"ext"`
	// 需要追加监听的目录,默认是'./'
	Paths []string `yaml:"paths"`
	// vendor目录下的文件是否也监听,默认是'false'
	Vendor bool `yaml:"vendor"`
	// 不需要监听的目录
	Exclude []string `yaml:"exclude"`
}

type Watcher

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

gowatch 对象

func NewWatcher

func NewWatcher(workPath string, config *Config) *Watcher

func (*Watcher) StartWatch

func (th *Watcher) StartWatch()

Jump to

Keyboard shortcuts

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