Skip to content

Commit

Permalink
Fix go get error
Browse files Browse the repository at this point in the history
  • Loading branch information
juho05 committed May 29, 2022
1 parent 920fa90 commit fb8a7fb
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions commands/new_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@ func newGoClient(projectName, serverURL, cgVersion string) error {
return err
}

out, err := external.ExecuteInDirHidden(projectName, "go", "mod", "init", module)
if err != nil {
if out != "" {
cli.Error(out)
}
return err
}

cli.Begin("Installing correct go-client version...")
libraryURL, libraryTag, err := getGoClientLibraryURL(projectName, cgVersion)
if err != nil {
return err
}

out, err := external.ExecuteInDirHidden(projectName, "go", "get", fmt.Sprintf("%s@%s", libraryURL, libraryTag))
out, err = external.ExecuteInDirHidden(projectName, "go", "get", fmt.Sprintf("%s@%s", libraryURL, libraryTag))
if err != nil {
if out != "" {
cli.Error(out)
Expand All @@ -50,7 +58,7 @@ func newGoClient(projectName, serverURL, cgVersion string) error {
cli.Finish()

cli.Begin("Creating project template...")
err = createGoClientTemplate(projectName, module, serverURL, libraryURL)
err = createGoClientTemplate(projectName, serverURL, libraryURL)
if err != nil {
return err
}
Expand Down Expand Up @@ -81,15 +89,7 @@ func newGoClient(projectName, serverURL, cgVersion string) error {
return nil
}

func createGoClientTemplate(projectName, module, serverURL, libraryURL string) error {
out, err := external.ExecuteInDirHidden(projectName, "go", "mod", "init", module)
if err != nil {
if out != "" {
cli.Error(out)
}
return err
}

func createGoClientTemplate(projectName, serverURL, libraryURL string) error {
tmpl, err := template.New("main.go").Parse(goClientMainTemplate)
if err != nil {
return err
Expand Down Expand Up @@ -143,6 +143,14 @@ func newGoServer(projectName string) error {
return err
}

out, err := external.ExecuteInDirHidden(projectName, "go", "mod", "init", module)
if err != nil {
if out != "" {
cli.Error(out)
}
return err
}

cli.Begin("Fetching latest version numbers...")
cgeVersion, err := external.LatestCGEVersion()
if err != nil {
Expand All @@ -164,7 +172,7 @@ func newGoServer(projectName string) error {

cli.Begin("Installing dependencies...")

out, err := external.ExecuteInDirHidden(projectName, "go", "mod", "tidy")
out, err = external.ExecuteInDirHidden(projectName, "go", "mod", "tidy")
if err != nil {
if out != "" {
cli.Error(out)
Expand All @@ -190,15 +198,7 @@ func newGoServer(projectName string) error {
}

func createGoServerTemplate(projectName, module, cgeVersion, libraryURL string) error {
out, err := external.ExecuteInDirHidden(projectName, "go", "mod", "init", module)
if err != nil {
if out != "" {
cli.Error(out)
}
return err
}

err = executeGoServerTemplate(goServerMainTemplate, "main.go", projectName, cgeVersion, libraryURL, module)
err := executeGoServerTemplate(goServerMainTemplate, "main.go", projectName, cgeVersion, libraryURL, module)
if err != nil {
return err
}
Expand Down

0 comments on commit fb8a7fb

Please sign in to comment.