Skip to content

Commit

Permalink
fix: remove rest of log.Println
Browse files Browse the repository at this point in the history
  • Loading branch information
kjuulh committed Apr 17, 2023
1 parent 0387ae3 commit 86f789f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions pkg/executors/golang/codegen/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package codegen

import (
"context"
"log"
"os/exec"
"path"

"github.com/lunarway/shuttle/pkg/ui"
)

func Format(ctx context.Context, shuttlelocaldir string) error {
func Format(ctx context.Context, ui *ui.UI, shuttlelocaldir string) error {
cmd := exec.Command("go", "fmt", "./...")
cmd.Dir = path.Join(shuttlelocaldir, "tmp")

output, err := cmd.CombinedOutput()
if err != nil {
log.Printf("%s\nerror: %v", string(output), err)
ui.Errorln("go fmt: %s, error: %v", string(output), err)
return err
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/executors/golang/codegen/tidy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package codegen

import (
"context"
"log"
"os/exec"
"path"

"github.com/lunarway/shuttle/pkg/ui"
)

func ModTidy(ctx context.Context, shuttlelocaldir string) error {
func ModTidy(ctx context.Context, ui *ui.UI, shuttlelocaldir string) error {
cmd := exec.Command("go", "mod", "tidy")
cmd.Dir = path.Join(shuttlelocaldir, "tmp")

output, err := cmd.CombinedOutput()
if err != nil {
log.Printf("%s\n", string(output))
ui.Errorln("mod tidy: %s, error: %v", string(output), err)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/executors/golang/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ func compile(ctx context.Context, ui *ui.UI, actions *discover.ActionsDiscovered
return "", err
}

if err = codegen.Format(ctx, shuttlelocaldir); err != nil {
if err = codegen.Format(ctx, ui, shuttlelocaldir); err != nil {
return "", err
}

if err = codegen.ModTidy(ctx, shuttlelocaldir); err != nil {
if err = codegen.ModTidy(ctx, ui, shuttlelocaldir); err != nil {
return "", err
}
binarypath, err := codegen.CompileBinary(ctx, ui, shuttlelocaldir)
Expand Down
3 changes: 1 addition & 2 deletions pkg/executors/golang/executer/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package executer

import (
"context"
"log"

"github.com/lunarway/shuttle/pkg/config"
"github.com/lunarway/shuttle/pkg/ui"
Expand All @@ -11,7 +10,7 @@ import (
func Run(ctx context.Context, ui *ui.UI, c *config.ShuttleProjectContext, path string, args ...string) error {
binaries, err := prepare(ctx, ui, path, c)
if err != nil {
log.Printf("failed to run command: %v", err)
ui.Errorln("failed to run command: %v", err)
return err
}

Expand Down

0 comments on commit 86f789f

Please sign in to comment.