From 180e433ba04d4002c574e950c3a3f7333a5e913c Mon Sep 17 00:00:00 2001 From: tyru Date: Wed, 8 Nov 2017 21:35:59 +0900 Subject: [PATCH] Remove revision variable, '-ldflags -X' injection * 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. --- Makefile | 7 +++---- cmd/version.go | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 2a6fc781..8b54e53d 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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) diff --git a/cmd/version.go b/cmd/version.go index d7a8a002..243996b0 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -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 }