Skip to content

Commit

Permalink
Send the version to stderr
Browse files Browse the repository at this point in the history
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. 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.
  • Loading branch information
greg0ire committed Dec 17, 2024
1 parent a83c4c0 commit e1affa6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/swag/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func initAction(ctx *cli.Context) error {
}

func main() {
fmt.Println("Swag version:", swag.Version)
fmt.Fprintln(os.Stderr, "Swag version:", swag.Version)
app := cli.NewApp()
app.Version = swag.Version
app.Usage = "Automatically generate RESTful API documentation with Swagger 2.0 for Go."
Expand Down

0 comments on commit e1affa6

Please sign in to comment.