github.com/wawandco/ox@v0.13.6-0.20230809142027-913b3d837f2a/plugins/tools/standard/initializer.go (about) 1 package standard 2 3 import ( 4 "context" 5 _ "embed" 6 "path/filepath" 7 8 "github.com/wawandco/ox/internal/runtime" 9 "github.com/wawandco/ox/internal/source" 10 "github.com/wawandco/ox/plugins/base/new" 11 ) 12 13 var ( 14 //go:embed templates/go.mod.tmpl 15 goModTemplate string 16 ) 17 18 type Initializer struct{} 19 20 func (i Initializer) Name() string { 21 return "standard/initializer" 22 } 23 24 // Initialize the go module 25 func (i *Initializer) Initialize(ctx context.Context, options new.Options) error { 26 opts := struct { 27 OxVersion string 28 ModuleName string 29 }{ 30 OxVersion: runtime.Version, 31 ModuleName: options.Module, 32 } 33 34 err := source.Build(filepath.Join(options.Folder, "go.mod"), goModTemplate, opts) 35 return err 36 }