API improvements

This commit is contained in:
Alex Yatskov 2015-12-19 21:01:54 +09:00
parent bb80029ef9
commit 1029f23558
3 changed files with 11 additions and 13 deletions

View File

@ -76,11 +76,8 @@ func (gs *goldsmith) queueFiles(target uint) {
}
func (gs *goldsmith) cleanupFiles() {
var (
files = make(chan string)
dirs = make(chan string)
)
files := make(chan string)
dirs := make(chan string)
go scanDir(gs.dstDir, files, dirs)
for files != nil || dirs != nil {
@ -133,10 +130,6 @@ func (gs *goldsmith) referenceFile(path string) {
gs.refMtx.Lock()
defer gs.refMtx.Unlock()
if gs.refs == nil {
gs.refs = make(map[string]bool)
}
path = cleanPath(path)
for {
@ -155,12 +148,13 @@ func (gs *goldsmith) fault(name string, f *file, err error) {
color.Red("Fault Detected\n")
color.Yellow("\tPlugin:\t%s\n", color.WhiteString(name))
color.Yellow("\tError:\t%s\n\n", color.WhiteString(err.Error()))
if f != nil {
color.Yellow("\tFile:\t%s\n", color.WhiteString(f.path))
}
color.Yellow("\tError:\t%s\n\n", color.WhiteString(err.Error()))
gs.tainted = true
}
//

View File

@ -45,7 +45,7 @@ func newStage(gs *goldsmith) *stage {
func (s *stage) chain(p Plugin) {
defer close(s.output)
name, flags, err := p.Initialize(s)
name, flags, err := p.Initialize()
if err != nil {
s.gs.fault(name, nil, err)
return

View File

@ -83,8 +83,8 @@ const (
PLUGIN_FLAG_BATCH = 1 << iota
)
type Plugin interface {
Initialize(ctx Context) (string, uint, error)
type Initializer interface {
Initialize() (string, uint, error)
}
type Accepter interface {
@ -98,3 +98,7 @@ type Finalizer interface {
type Processor interface {
Process(ctx Context, f File) (bool, error)
}
type Plugin interface {
Initializer
}