github.com/wawandco/oxpecker@v1.5.7-0.20210910201653-5958d4afdd89/tools/standard/initializer.go (about)

     1  package standard
     2  
     3  import (
     4  	"context"
     5  	_ "embed"
     6  	"path/filepath"
     7  
     8  	"github.com/wawandco/oxpecker/internal/source"
     9  	"github.com/wawandco/oxpecker/lifecycle/new"
    10  )
    11  
    12  var (
    13  	//go:embed templates/go.mod.tmpl
    14  	goModTemplate string
    15  )
    16  
    17  type Initializer struct{}
    18  
    19  func (i Initializer) Name() string {
    20  	return "standard/initializer"
    21  }
    22  
    23  // Initialize the go module
    24  func (i *Initializer) Initialize(ctx context.Context, options new.Options) error {
    25  	err := source.Build(filepath.Join(options.Folder, "go.mod"), goModTemplate, options.Module)
    26  	return err
    27  }