Skip to content

Commit 1eb7125

Browse files
vearutopjirfag
authored andcommitted
Add version information to built artifact when go get with go1.12
1 parent deb63b1 commit 1eb7125

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ Local installation is not recommended for your CI pipeline. Only install the lin
9696
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
9797
```
9898

99+
With `go1.11` or later you can get a particular version
100+
```bash
101+
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/[email protected]
102+
```
103+
99104
#### MacOS
100105

101106
You can also install it on MacOS using [brew](https://brew.sh/):

README.tmpl.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ Local installation is not recommended for your CI pipeline. Only install the lin
9696
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
9797
```
9898

99+
With `go1.11` or later you can get a particular version
100+
```bash
101+
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/[email protected]
102+
```
103+
99104
#### MacOS
100105

101106
You can also install it on MacOS using [brew](https://brew.sh/):

cmd/golangci-lint/mod_version.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// +build go1.12
2+
3+
package main
4+
5+
import (
6+
"fmt"
7+
"runtime/debug"
8+
)
9+
10+
func init() {
11+
if info, available := debug.ReadBuildInfo(); available {
12+
if date == "" && info.Main.Version != "(devel)" {
13+
version = info.Main.Version
14+
commit = fmt.Sprintf("(unknown, mod sum: %q)", info.Main.Sum)
15+
date = "(unknown)"
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)