mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Add version command to print version info
This commit is contained in:
@@ -49,6 +49,11 @@ cd cmd/boringproxy
|
||||
go build
|
||||
```
|
||||
|
||||
To build with version information:
|
||||
```bash
|
||||
go build -ldflags "-X main.Version=$(git describe --tags)"
|
||||
```
|
||||
|
||||
Give the executable permission to bind low ports (ie 80/443):
|
||||
|
||||
```bash
|
||||
|
||||
@@ -12,12 +12,15 @@ import (
|
||||
const usage = `Usage: %s [command] [flags]
|
||||
|
||||
Commands:
|
||||
version Prints version information.
|
||||
server Start a new server.
|
||||
client Connect to a server.
|
||||
|
||||
Use "%[1]s command -h" for a list of flags for the command.
|
||||
`
|
||||
|
||||
var Version string
|
||||
|
||||
func fail(msg string) {
|
||||
fmt.Fprintln(os.Stderr, msg)
|
||||
os.Exit(1)
|
||||
@@ -33,6 +36,8 @@ func main() {
|
||||
command := os.Args[1]
|
||||
|
||||
switch command {
|
||||
case "version":
|
||||
fmt.Println(Version)
|
||||
case "help", "-h", "--help", "-help":
|
||||
fmt.Printf(usage, os.Args[0])
|
||||
case "server":
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo Building platform $1-$2
|
||||
CGO_ENABLED=0 GOOS=$1 GOARCH=$2 go build -o build/boringproxy-$1-$2$3
|
||||
CGO_ENABLED=0 GOOS=$1 GOARCH=$2 go build -ldflags "-X main.Version=$(git describe --tags)" -o build/boringproxy-$1-$2$3
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo Building platform $1-x86_64
|
||||
CGO_ENABLED=0 GOOS=$1 GOARCH=amd64 go build -o build/boringproxy-$1-x86_64$2
|
||||
CGO_ENABLED=0 GOOS=$1 GOARCH=amd64 go build -ldflags "-X main.Version=$(git describe --tags)" -o build/boringproxy-$1-x86_64$2
|
||||
|
||||
Reference in New Issue
Block a user