Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions trainings/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ func writeGitignore(trainingRootFs *afero.BasePathFs) error {
}

func createGoWorkspace(trainingRoot string) error {
if !hasGo() {
return nil
}

cmd := exec.Command("go", "work", "init")
cmd.Dir = trainingRoot

Expand All @@ -201,6 +205,10 @@ func hasGoWorkspace(trainingRoot string) bool {
}

func addModuleToWorkspace(trainingRoot string, modulePath string) error {
if !hasGo() {
return nil
}

if !hasGoWorkspace(trainingRoot) {
return nil
}
Expand All @@ -217,6 +225,11 @@ func addModuleToWorkspace(trainingRoot string, modulePath string) error {
return nil
}

func hasGo() bool {
_, err := exec.LookPath("go")
return err == nil
}

func (h *Handlers) showTrainingStartPrompt(trainingDir string) error {
fmt.Printf(
"This command will clone training source code to %s directory.\n",
Expand Down