From 434e755419b9ad341940688358789e28a6e621cc Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 4 Sep 2016 11:43:04 -0700 Subject: [PATCH] Explicitly prevent instance reuse --- core.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core.go b/core.go index 8421c37..19fa694 100644 --- a/core.go +++ b/core.go @@ -32,6 +32,7 @@ type goldsmith struct { srcDir, dstDir string contexts []*context refs map[string]bool + complete bool errors []error errorMtx sync.Mutex @@ -102,11 +103,19 @@ func (gs *goldsmith) fault(name string, f *file, err error) { // func (gs *goldsmith) Chain(p Plugin, filters ...string) Goldsmith { + if gs.complete { + panic("attempted reuse of goldsmith instance") + } + gs.pushContext(p, filters) return gs } func (gs *goldsmith) End(dstDir string) []error { + if gs.complete { + panic("attempted reuse of goldsmith instance") + } + gs.dstDir = dstDir for _, ctx := range gs.contexts { @@ -119,5 +128,7 @@ func (gs *goldsmith) End(dstDir string) []error { } gs.cleanupFiles() + gs.complete = true + return gs.errors }