Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly respect file flag for protoc-gen-swagger #293

Merged
merged 2 commits into from
Feb 16, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions protoc-gen-swagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

var (
importPrefix = flag.String("import_prefix", "", "prefix to be added to go package paths for imported proto files")
file = flag.String("file", "stdin", "where to load data from")
file = flag.String("file", "-", "where to load data from")
allowDeleteBody = flag.Bool("allow_delete_body", false, "unless set, HTTP DELETE methods may not have a body")
)

Expand Down Expand Up @@ -45,8 +45,12 @@ func main() {

glog.V(1).Info("Processing code generator request")
f := os.Stdin
if *file != "stdin" {
f, _ = os.Open("input.txt")
if *file != "-" {
var err error
f, err = os.Open(*file)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not f, err := os.Open(*file)? without the var on the above line? Is there variable shadowing I'm missing here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@achew that would define a new f instead of assigning to the one created previously.

if err != nil {
glog.Fatal(err)
}
}
req, err := parseReq(f)
if err != nil {
Expand Down