Description
What version of Go are you using (go version
)?
go version go1.7.3 linux/amd64
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/iterion/dev/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build201245685=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="0"
What did you do?
Run this build command with github.com/iterion/remotepkg
in the vendor directory:
note: package above doesn't actually exist yet, but I can create it if needed for demonstration purposes.
go build -a -installsuffix cgo -o test -ldflags "-X github.com/iterion/remotepkg.timestamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'`" .
main.go
package main
import (
"github.com/iterion/remotepkg"
)
func main() {
remotepkg.PrintEnv()
}
remotepkg.go
package remotepkg
import (
"log"
)
var timestamp string
func PrintEnv() {
log.Println(timestamp)
}
What did you expect to see?
Expect ./test
to print build time.
What did you see instead?
Nothing is printed.
If the remote package is not in the vendor dir but does exist in your gopath in an expected place then the build time is correctly printed.