本文整理匯總了Golang中github.com/cortesi/devd/livereload.Reloader類的典型用法代碼示例。如果您正苦於以下問題:Golang Reloader類的具體用法?Golang Reloader怎麽用?Golang Reloader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Reloader類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: WatchPaths
// WatchPaths watches a set of paths, and broadcasts changes through reloader.
func WatchPaths(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger) error {
ch := make(chan []string, 1)
for _, path := range paths {
absPath, err := filepath.Abs(path)
if err != nil {
return err
}
if absPath[len(absPath)-1] != filepath.Separator {
absPath += string(filepath.Separator)
}
pathchan := make(chan []string, 1)
err = watch.Watch(path, batchTime, pathchan)
if err != nil {
return err
}
go func() {
for files := range pathchan {
files = filterFiles(absPath, files, excludePatterns, log)
if len(files) > 0 {
ch <- files
}
}
}()
}
go reloader.Watch(ch)
return nil
}
示例2: WatchRoutes
// WatchRoutes watches the route collection, and broadcasts changes through reloader.
func WatchRoutes(routes RouteCollection, reloader livereload.Reloader, excludePatterns []string, log termlog.Logger) error {
c := make(chan []string, 1)
for i := range routes {
err := routes[i].Watch(c, excludePatterns, log)
if err != nil {
return err
}
}
go reloader.Watch(c)
return nil
}
示例3: WatchPaths
// WatchPaths watches a set of paths, and broadcasts changes through reloader.
func WatchPaths(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger) error {
ch := make(chan []string, 1)
for _, path := range paths {
modchan := make(chan modd.Mod, 1)
err := modd.Watch([]string{path}, excludePatterns, batchTime, modchan)
if err != nil {
return err
}
go func() {
for mod := range modchan {
ch <- mod.All()
}
}()
}
go reloader.Watch(ch)
return nil
}
示例4: WatchPaths
// WatchPaths watches a set of paths, and broadcasts changes through reloader.
func WatchPaths(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger) error {
ch := make(chan []string, 1)
for _, path := range paths {
modchan := make(chan modd.Mod, 1)
err := modd.Watch(path, batchTime, modchan)
if err != nil {
return err
}
go func() {
for mod := range modchan {
files := filterFiles(mod.All(), excludePatterns, log)
if len(files) > 0 {
ch <- files
}
}
}()
}
go reloader.Watch(ch)
return nil
}
示例5: WatchPaths
// WatchPaths watches a set of paths, and broadcasts changes through reloader.
func WatchPaths(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger) error {
ch := make(chan []string, 1)
for _, path := range paths {
modchan := make(chan *moddwatch.Mod, 1)
_, err := moddwatch.Watch([]string{path}, batchTime, modchan)
if err != nil {
return err
}
go func() {
for mod := range modchan {
filteredMod, err := mod.Filter([]string{"**/*"}, excludePatterns)
if err != nil {
log.Shout("Error filtering watches: %s", err)
}
if !filteredMod.Empty() {
ch <- filteredMod.All()
}
}
}()
}
go reloader.Watch(ch)
return nil
}