Skip to content

Commit

Permalink
Merge pull request #24 from urfave/go-modules-support
Browse files Browse the repository at this point in the history
Add support for Go Modules
  • Loading branch information
asahasrabuddhe authored Sep 7, 2019
2 parents 0e5ce16 + 1cced0d commit 05c3798
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions runnable.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,28 @@ func (rn *Runnable) Run(i int) *runResult {

nameBase := strings.Replace(tmpFile.Name(), "."+rn.Frob.Extension(), "", 1)

// look out for go files
if rn.Frob.Extension() == "go" {
// check if GO111MODULE env variable is set
if go111module := os.Getenv("GO111MODULE"); go111module != "" {
// if GO111MODULE is set and is not set to auto, proceed with create go module
if go111module != "auto" {
modFile, err := os.Create(filepath.Join(tmpDir, "go.mod"))
if err != nil {
return &runResult{Runnable: rn, Retcode: -1, Error: err}
}

if _, err := modFile.Write([]byte(fmt.Sprintf("module example%d", rn.LineOffset))); err != nil {
return &runResult{Runnable: rn, Retcode: -1, Error: err}
}

if err := modFile.Close(); err != nil {
return &runResult{Runnable: rn, Retcode: -1, Error: err}
}
}
}
}

expandedCommands := []*command{}

tmplVars := map[string]string{
Expand Down

0 comments on commit 05c3798

Please sign in to comment.