Skip to content

Commit

Permalink
Remove revision variable, '-ldflags -X' injection
Browse files Browse the repository at this point in the history
* Most users would do 'go get' instead of 'make'
* 'revision' value is always "Devel" when built by 'make'

Thus 'revision' variable is meaningless, remove it.
  • Loading branch information
tyru committed Nov 8, 2017
1 parent a411a09 commit 180e433
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

NAME := volt
SRC := $(wildcard *.go */*.go)
VERSION := $(shell bin/volt version | sed -E 's/^volt version: (\S+).*/\1/')
DEVEL_LDFLAGS := -X github.com/vim-volt/go-volt/cmd.revision=$(git rev-parse --short HEAD)
RELEASE_LDFLAGS := $(DEVEL_LDFLAGS) -extldflags '-static'
VERSION := $(shell sed -n -E 's/var version string = "([^"]+)"/\1/p' cmd/version.go)
RELEASE_LDFLAGS := -extldflags '-static'
RELEASE_OS := linux windows darwin
RELEASE_ARCH := amd64 386

Expand All @@ -13,7 +12,7 @@ BIN_DIR := bin
all: $(BIN_DIR)/$(NAME)

$(BIN_DIR)/$(NAME): $(SRC)
go build -ldflags "$(DEVEL_LDFLAGS)" -o $(BIN_DIR)/$(NAME)
go build -o $(BIN_DIR)/$(NAME)

setup:
@which go >/dev/null 2>&1 || (echo '[Error] You need to install go,make commands'; exit 1)
Expand Down
3 changes: 1 addition & 2 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package cmd
import "fmt"

var version string = "v0.0.3"
var revision string = "Devel"

func Version(args []string) int {
fmt.Printf("volt version: %s (rev %s)\n", version, revision)
fmt.Printf("volt version: %s\n", version)

return 0
}

0 comments on commit 180e433

Please sign in to comment.