Skip to content

Commit 14c57e5

Browse files
authored
Merge pull request #31 from ThreeDotsLabs/skip-go
Skip "go work" commands on systems with no Go installed
2 parents 538a26a + dce44ed commit 14c57e5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

trainings/init.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ func writeGitignore(trainingRootFs *afero.BasePathFs) error {
178178
}
179179

180180
func createGoWorkspace(trainingRoot string) error {
181+
if !hasGo() {
182+
return nil
183+
}
184+
181185
cmd := exec.Command("go", "work", "init")
182186
cmd.Dir = trainingRoot
183187

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

203207
func addModuleToWorkspace(trainingRoot string, modulePath string) error {
208+
if !hasGo() {
209+
return nil
210+
}
211+
204212
if !hasGoWorkspace(trainingRoot) {
205213
return nil
206214
}
@@ -217,6 +225,11 @@ func addModuleToWorkspace(trainingRoot string, modulePath string) error {
217225
return nil
218226
}
219227

228+
func hasGo() bool {
229+
_, err := exec.LookPath("go")
230+
return err == nil
231+
}
232+
220233
func (h *Handlers) showTrainingStartPrompt(trainingDir string) error {
221234
fmt.Printf(
222235
"This command will clone training source code to %s directory.\n",

0 commit comments

Comments
 (0)