Skip to content

Commit 68c9ab5

Browse files
fix: replace fmt.Fprintln with slog (#2231)
1 parent 9bbcc5a commit 68c9ab5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

cmd/github-comment/main.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package main
22

33
import (
44
"context"
5-
"fmt"
65
"log/slog"
76
"os"
87
"os/signal"
98

109
"github.com/suzuki-shunsuke/github-comment/v6/pkg/cmd"
1110
"github.com/suzuki-shunsuke/go-error-with-exit-code/ecerror"
11+
"github.com/suzuki-shunsuke/slog-error/slogerr"
1212
"github.com/suzuki-shunsuke/slog-util/slogutil"
1313
)
1414

@@ -19,13 +19,10 @@ var (
1919
)
2020

2121
func main() {
22-
if err := core(); err != nil {
23-
fmt.Fprintln(os.Stderr, err)
24-
os.Exit(ecerror.GetExitCode(err))
25-
}
22+
os.Exit(core())
2623
}
2724

28-
func core() error {
25+
func core() int {
2926
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
3027
defer cancel()
3128
logLevelVar := &slog.LevelVar{}
@@ -47,5 +44,9 @@ func core() error {
4744
Date: date,
4845
},
4946
}
50-
return runner.Run(ctx, os.Args) //nolint:wrapcheck
47+
if err := runner.Run(ctx, os.Args); err != nil {
48+
slogerr.WithError(logger, err).Error("github-comment failed")
49+
return ecerror.GetExitCode(err)
50+
}
51+
return 0
5152
}

0 commit comments

Comments
 (0)