API improvements
This commit is contained in:
parent
bb80029ef9
commit
1029f23558
14
goldsmith.go
14
goldsmith.go
@ -76,11 +76,8 @@ func (gs *goldsmith) queueFiles(target uint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gs *goldsmith) cleanupFiles() {
|
func (gs *goldsmith) cleanupFiles() {
|
||||||
var (
|
files := make(chan string)
|
||||||
files = make(chan string)
|
dirs := make(chan string)
|
||||||
dirs = make(chan string)
|
|
||||||
)
|
|
||||||
|
|
||||||
go scanDir(gs.dstDir, files, dirs)
|
go scanDir(gs.dstDir, files, dirs)
|
||||||
|
|
||||||
for files != nil || dirs != nil {
|
for files != nil || dirs != nil {
|
||||||
@ -133,10 +130,6 @@ func (gs *goldsmith) referenceFile(path string) {
|
|||||||
gs.refMtx.Lock()
|
gs.refMtx.Lock()
|
||||||
defer gs.refMtx.Unlock()
|
defer gs.refMtx.Unlock()
|
||||||
|
|
||||||
if gs.refs == nil {
|
|
||||||
gs.refs = make(map[string]bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
path = cleanPath(path)
|
path = cleanPath(path)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -155,12 +148,13 @@ func (gs *goldsmith) fault(name string, f *file, err error) {
|
|||||||
|
|
||||||
color.Red("Fault Detected\n")
|
color.Red("Fault Detected\n")
|
||||||
color.Yellow("\tPlugin:\t%s\n", color.WhiteString(name))
|
color.Yellow("\tPlugin:\t%s\n", color.WhiteString(name))
|
||||||
|
color.Yellow("\tError:\t%s\n\n", color.WhiteString(err.Error()))
|
||||||
if f != nil {
|
if f != nil {
|
||||||
color.Yellow("\tFile:\t%s\n", color.WhiteString(f.path))
|
color.Yellow("\tFile:\t%s\n", color.WhiteString(f.path))
|
||||||
}
|
}
|
||||||
color.Yellow("\tError:\t%s\n\n", color.WhiteString(err.Error()))
|
|
||||||
|
|
||||||
gs.tainted = true
|
gs.tainted = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
2
stage.go
2
stage.go
@ -45,7 +45,7 @@ func newStage(gs *goldsmith) *stage {
|
|||||||
func (s *stage) chain(p Plugin) {
|
func (s *stage) chain(p Plugin) {
|
||||||
defer close(s.output)
|
defer close(s.output)
|
||||||
|
|
||||||
name, flags, err := p.Initialize(s)
|
name, flags, err := p.Initialize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.gs.fault(name, nil, err)
|
s.gs.fault(name, nil, err)
|
||||||
return
|
return
|
||||||
|
8
types.go
8
types.go
@ -83,8 +83,8 @@ const (
|
|||||||
PLUGIN_FLAG_BATCH = 1 << iota
|
PLUGIN_FLAG_BATCH = 1 << iota
|
||||||
)
|
)
|
||||||
|
|
||||||
type Plugin interface {
|
type Initializer interface {
|
||||||
Initialize(ctx Context) (string, uint, error)
|
Initialize() (string, uint, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Accepter interface {
|
type Accepter interface {
|
||||||
@ -98,3 +98,7 @@ type Finalizer interface {
|
|||||||
type Processor interface {
|
type Processor interface {
|
||||||
Process(ctx Context, f File) (bool, error)
|
Process(ctx Context, f File) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Plugin interface {
|
||||||
|
Initializer
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user