watch

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 15 Imported by: 1

Documentation

Overview

Package watch 监视文件变化并编译

Index

Constants

View Source
const MinWatcherFrequency = 1 * time.Second

MinWatcherFrequency 监视器更新频率的最小值

Variables

This section is empty.

Functions

func Watch

func Watch(ctx context.Context, logs chan<- *log.Log, opt *Options) error

Watch 执行热编译服务

如果初始化参数有误,则反错误信息,如果是编译过程中出错,将直接将错误内容输出到 logs。

Types

type Flags

type Flags map[string]string

func (Flags) MarshalXML

func (f Flags) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Flags) UnmarshalXML

func (f *Flags) UnmarshalXML(d *xml.Decoder, s xml.StartElement) error

type Options

type Options struct {
	XMLName struct{} `xml:"gobuild" json:"-" yaml:"-"`

	// 指定本地化的输出对象
	//
	// 如果为空,表示原样输出,不具备本地化的功能。
	Printer *message.Printer `xml:"-" json:"-" yaml:"-"`

	// 为 go build 最后的文件参数
	//
	// 可以为空,表示当前目录。
	MainFiles string `xml:"main" json:"main" yaml:"main"`

	// 指定可执行文件输出的文件路径
	//
	// 为空表示默认值,若不带路径信息,会附加在 Dirs 的第一个路径上;
	//
	// windows 系统无须指定 .exe 扩展名,会自行添加。
	//
	// 如果带路径信息,则会使用该文件所在目录作为工作目录。
	OutputName string `xml:"output" json:"output" yaml:"output"`

	// 传递各个工具的参数
	//
	// 大致有以下几个,具体可参考 go build 的 xxflags 系列参数。
	//  - asm   --> asmflags
	//  - gccgo --> gccgoflags
	//  - gc    --> gcflags
	//  - ld    --> ldflags
	Flags Flags `xml:"flags" json:"flags" yaml:"flags"`

	// 指定监视的文件扩展名
	//
	// 为空表示不监视任何文件
	Exts []string `xml:"exts" json:"exts" yaml:"exts"`

	// 传递给编译成功后的程序的参数
	AppArgs string `xml:"args" yaml:"args" json:"args"`

	// 是否监视子目录
	Recursive bool `xml:"recursive" yaml:"recursive" json:"recursive"`

	// 表示需要监视的目录
	//
	// 至少指定一个目录,第一个目录被当作主目录,将编译其下的文件作为执行主体。
	//
	// 如果 OutputName 中未指定目录的话,第一个目录会被当作工作目录使用。
	Dirs []string `xml:"dirs" yaml:"dirs" json:"dirs"`

	// 监视器的更新频率
	//
	// 只有文件更新的时长超过此值,才会被定义为更新。防止文件频繁修改导致的频繁编译调用。
	//
	// 此值不能小于 [MinWatcherFrequency]。
	//
	// 默认值为 [MinWatcherFrequency]。
	WatcherFrequency time.Duration `xml:"freq" yaml:"freq" json:"freq"`
	// contains filtered or unexported fields
}

Options 热编译的选项

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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