From 0ed4ebbd0bbc769166aa532e2e475488aa9c6453 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Tue, 12 Feb 2019 12:13:23 +0100 Subject: [PATCH] Add go1.12 versioning support --- cli/README.md | 5 +++++ cmd/migrate/mod_version.go | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 cmd/migrate/mod_version.go diff --git a/cli/README.md b/cli/README.md index 472cc4187..afd5455d4 100644 --- a/cli/README.md +++ b/cli/README.md @@ -32,6 +32,11 @@ $ apt-get install -y migrate $ go get -tags 'postgres' -u github.com/golang-migrate/migrate/cmd/migrate ``` +##### Versioned with Go Modules (go1.12) +``` +$ GO111MODULE=on go get -tags 'postgres' -u github.com/golang-migrate/migrate/cmd/migrate@v4.2.4 +``` + ##### Versioned ``` diff --git a/cmd/migrate/mod_version.go b/cmd/migrate/mod_version.go new file mode 100644 index 000000000..97c6cd4f0 --- /dev/null +++ b/cmd/migrate/mod_version.go @@ -0,0 +1,11 @@ +// +build go1.12 + +package main + +func init() { + if info, available := debug.ReadBuildInfo(); available { + if Version == "dev" { + Version = info.Main.Version + } + } +}