github.com/axxelG/goreleaser@v0.92.0/pkg/build/build.go (about) 1 // Package build provides the API for external builders 2 package build 3 4 import ( 5 "sync" 6 7 "github.com/goreleaser/goreleaser/pkg/config" 8 "github.com/goreleaser/goreleaser/pkg/context" 9 ) 10 11 var ( 12 builders = map[string]Builder{} 13 lock sync.Mutex 14 ) 15 16 // Register registers a builder to a given lang 17 func Register(lang string, builder Builder) { 18 lock.Lock() 19 builders[lang] = builder 20 lock.Unlock() 21 } 22 23 // For gets the previously registered builder for the given lang 24 func For(lang string) Builder { 25 return builders[lang] 26 } 27 28 // Options to be passed down to a builder 29 type Options struct { 30 Name, Path, Ext, Target string 31 } 32 33 // Builder defines a builder 34 type Builder interface { 35 WithDefaults(build config.Build) config.Build 36 Build(ctx *context.Context, build config.Build, options Options) error 37 }