-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
42 lines (33 loc) · 874 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"os"
"path/filepath"
"runtime"
"runtime/debug"
"golang.org/x/tools/go/analysis/singlechecker"
"github.com/breml/bidichk/pkg/bidichk"
)
var (
version = "development"
commit = ""
date = ""
)
func main() {
bidichk.Version = buildVersion()
singlechecker.Main(bidichk.NewAnalyzer())
}
func buildVersion() string {
result := fmt.Sprintf("%s version %s", filepath.Base(os.Args[0]), version)
if commit != "" {
result = fmt.Sprintf("%s\ncommit: %s", result, commit)
}
if date != "" {
result = fmt.Sprintf("%s\nbuilt at: %s", result, date)
}
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" {
result = fmt.Sprintf("%s\nmodule version: %s, checksum: %s", result, info.Main.Version, info.Main.Sum)
}
result = fmt.Sprintf("%s\ngoos: %s\ngoarch: %s", result, runtime.GOOS, runtime.GOARCH)
return result
}