Skip to content

Commit

Permalink
cmd/xurls: add a version global var
Browse files Browse the repository at this point in the history
Since our build script expects it.
This does mean we will build our release binaries one commit after
the v2.5.0 tag, but so be it. I don't really want to do a v2.5.1.
  • Loading branch information
mvdan committed Apr 16, 2023
1 parent 6f8fb63 commit 67e809b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cmd/xurls/main.go
Expand Up @@ -26,12 +26,14 @@ import (
)

var (
matching = flag.String("m", "", "")
relaxed = flag.Bool("r", false, "")
fix boolString
version = flag.Bool("version", false, "")
matching = flag.String("m", "", "")
relaxed = flag.Bool("r", false, "")
fix boolString
versionFlag = flag.Bool("version", false, "")
)

var version string

type boolString string

func (s *boolString) Set(val string) error {
Expand Down Expand Up @@ -214,7 +216,7 @@ func main() { os.Exit(main1()) }

func main1() int {
flag.Parse()
if *version {
if *versionFlag {
fmt.Println(readVersion())
return 0
}
Expand Down Expand Up @@ -258,6 +260,9 @@ func main1() int {
// Borrowed from https://github.com/burrowers/garble.

func readVersion() string {
if version != "" {
return version
}
info, ok := debug.ReadBuildInfo()
if !ok {
return "unknown"
Expand Down

0 comments on commit 67e809b

Please sign in to comment.