gorun

package
v0.0.0-...-8930970 Latest Latest
Warning

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

Go to latest
Published: May 20, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// IgnoreFiles 忽略的文件正则表达式
	IgnoreFiles = []string{
		`.#(\w+).go`, `.(\w+).go.swp`, `(\w+).go~`, `(\w+).tmp`,
	}
	// WatchExts 监视的文件扩展名
	WatchExts = []string{".go"}
)

Functions

func Printf

func Printf(format string, v ...interface{})

Printf Wrapper for log.Printf

func SetVerbose

func SetVerbose()

SetVerbose enable verbose mode

func StringSliceDiff

func StringSliceDiff(a, b []string) []string

StringSliceDiff a - b

func StringSliceUniq

func StringSliceUniq(a []string) []string

StringSliceUniq 获取唯一的String Slice TODO: 改进算法

Types

type CollectOption

type CollectOption struct {
	// 忽略vendor目录
	IgnoreVendor bool
}

CollectOption 依赖收集配置

type Collector

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

Collector 依赖收集/更新器

func NewCollector

func NewCollector(pwd string, gofiles []string, option *CollectOption) (*Collector, error)

NewCollector 收集器构造函数

func (*Collector) GetWatchDirs

func (c *Collector) GetWatchDirs() []string

GetWatchDirs 获取可以被监听的目录

func (*Collector) Update

func (c *Collector) Update(files []string) (*DepUpdate, error)

Update 文件变动,需要重新计算依赖,并获取需要移除和添加的目录监听列表 更新方法: * 文件更新:获取go文件对应的dir(一个go文件一定属于一个目录,一个目录的所有文件都属于 同一个包), 然后在获取到dir关联的Pkg对象。重新导入该包,计算其新增或删除的依赖

type DepUpdate

type DepUpdate struct {
	Added, Removed []string
}

DepUpdate 依赖更新记录

type Filter

type Filter = func(pkg *build.Package) bool

Filter 过滤依赖包

type Pkg

type Pkg struct {
	// pkg name
	Name string
	// pkg import path
	ImportPath string
	// pkg absoluted dir
	Dir string
	// pkg watchable denpencies
	Dep map[string]*Pkg
	// all imports
	Imports []string
	// contains filtered or unexported fields
}

Pkg 依赖树表示

func (*Pkg) ToDir

func (p *Pkg) ToDir() string

ToDir 获取依赖所在的目录

type Runner

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

Runner 运行器

func NewRunner

func NewRunner(args []string) *Runner

NewRunner 运行器构造函数

func (*Runner) Kill

func (r *Runner) Kill()

Kill 杀死进程

func (*Runner) Restart

func (r *Runner) Restart()

Restart 重启

func (*Runner) Run

func (r *Runner) Run()

Run 运行

type Updater

type Updater = func(files []string) *DepUpdate

Updater 更新器

type Watcher

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

Watcher 文件更新监听器

func NewWatcher

func NewWatcher(initWatchDir []string, update Updater) (*Watcher, error)

NewWatcher Watcher构造函数

Jump to

Keyboard shortcuts

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