-
Notifications
You must be signed in to change notification settings - Fork 20
🚸 Execute go mod tidy after basic creation
#123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
a3f82fb
3f60284
432ef3a
66f65f0
941a87d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,7 +78,18 @@ func createBasic(projectPath, modName string) (err error) { | |
| return | ||
| } | ||
|
|
||
| return runCmd(execCommand("go", "mod", "init", modName)) | ||
| if err = runCmd(execCommand("go", "mod", "init", modName)); err != nil{ | ||
| return | ||
| } | ||
|
|
||
| //Execute go mod tidy in the project directory | ||
| installModules := execCommand("go", "mod", "tidy") | ||
| installModules.Dir = fmt.Sprintf("%s%c", projectPath, os.PathSeparator) | ||
| if err = runCmd(installModules); err != nil{ | ||
| return | ||
| } | ||
gaby marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+94
to
+98
|
||
|
|
||
| return | ||
| } | ||
|
|
||
| const githubPrefix = "https://github.com/" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createBasicrunsgo mod initwithout settingCmd.Dir, but setsCmd.Dirforgo mod tidy. Since the function already receivesprojectPath, it would be more robust/consistent to setDirfor both commands (and avoid relying on a prioros.Chdir). This also preventsgo.modbeing created in the wrong directory ifcreateBasicis ever called withoutcreateProject.