Skip to content

protoc-gen-go: Add -version flag to print version #599

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
14 changes: 14 additions & 0 deletions protoc-gen-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,28 @@
package main

import (
"flag"
"io/ioutil"
"os"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/generator"
)

const (
// versionString holds the current version of protoc-gen-go.
versionString = "1.1.0"
)

func main() {
// If the -version flag is set, just print the version and exit.
versionFlag := flag.Bool("version", false, "print the version of protoc-gen-go")
flag.Parse()
if *versionFlag {
os.Stdout.WriteString(versionString)
os.Exit(0)
}

// Begin by allocating a generator. The request and response structures are stored there
// so we can do error handling easily - the response structure contains the field to
// report failure.
Expand Down