Skip to content

Commit 088b773

Browse files
committed
Send the version to stderr
Until https://tip.golang.org/doc/modules/managing-dependencies#tools is available to me, I have a shell script that detects the version of swag by invoking swag --version and parsing its output, then updates if I'm not using the version specified in the script. With v2, the output looks like this Swag version: v2.0.0 swag version v2.0.0 While it might be useful to have the swag version always printed for troubleshooting purposes, I think it should be printed to stderr so as not to mess up output that is supposed to be parsed. This change will result in the first line to be sent to stderr, making it backward-compatible with the previous output of swag --version while still retaining the improvement of having it printed for every command.
1 parent a83c4c0 commit 088b773

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmd/swag/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func initAction(ctx *cli.Context) error {
279279
}
280280

281281
func main() {
282-
fmt.Println("Swag version:", swag.Version)
282+
fmt.Fprintln(os.Stderr, "Swag version:", swag.Version)
283283
app := cli.NewApp()
284284
app.Version = swag.Version
285285
app.Usage = "Automatically generate RESTful API documentation with Swagger 2.0 for Go."

0 commit comments

Comments
 (0)