From ad3bf1eb589a501f12bf45bac188fc58cd16aad7 Mon Sep 17 00:00:00 2001 From: Denis Isaev Date: Sun, 3 Jun 2018 09:25:47 +0300 Subject: [PATCH] fix --version option and improve installation section of docs --- README.md | 37 +++++++++++++++++++++---------------- README.md.tmpl | 37 +++++++++++++++++++++---------------- pkg/commands/executor.go | 9 ++++----- pkg/commands/root.go | 2 +- 4 files changed, 47 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 08264929..2bc6a12d 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,9 @@ Sponsored by [GolangCI.com](https://golangci.com): SaaS service for running lint * [Install](#install) * [Quick Start](#quick-start) * [Comparison](#comparison) - * [golangci-lint vs gometalinter](#golangci-lint-vs-gometalinter) - * [golangci-lint vs Run Needed Linters Manually](#golangci-lint-vs-run-needed-linters-manually) * [Performance](#performance) - * [Comparison with gometalinter](#comparison-with-gometalinter) * [Supported Linters](#supported-linters) - * [Enabled By Default Linters](#enabled-by-default-linters) - * [Disabled By Default Linters (-E/--enable)](#disabled-by-default-linters--e--enable) * [Configuration](#configuration) - * [Command-Line Options](#command-line-options) - * [Configuration File](#configuration-file) * [False Positives](#false-positives) * [IDE integrations](#ide-integrations) * [Internals](#internals) @@ -40,7 +33,26 @@ Short 1.5 min video demo of analyzing [beego](https://github.com/astaxie/beego). [![asciicast](https://asciinema.org/a/183662.png)](https://asciinema.org/a/183662) # Install -Recommended way to install is: +## CI Installation +The most installations are done for CI (travis, circleci etc). It's important to have reproducable CI: +don't start to fail all builds at one moment. With golangci-lint this can cappen if you +use `--enable-all` and new linter is added or even without `--enable-all`: when one linter +was upgraded from the upstream. + +Therefore it's highly recommended to install a fixed version of golangci-lint. +Find needed version on the [releases page](https://github.com/golangci/golangci-lint/releases). + +The recommended way to install golangci-lint is the next: +```bash +curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s VERSION +``` + +Periodically update version of golangci-lint: we do active development +and deliver a lot of improvements. But do it explicitly with checking of +newly found issues. + +## Local Installation +It's a not recommended for CI method. Do it only for the local development. ```bash go get -u github.com/golangci/golangci-lint/cmd/golangci-lint ``` @@ -48,16 +60,9 @@ go get -u github.com/golangci/golangci-lint/cmd/golangci-lint You can also install it by brew: ```bash brew install golangci/tap/golangci-lint +brew upgrade golangci/tap/golangci-lint ``` -For CI you can use fast local installation: -```bash -curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -``` - -Check the [releases page](https://github.com/golangci/golangci-lint/releases) to fix the version. - - # Quick Start To run golangci-lint execute: ```bash diff --git a/README.md.tmpl b/README.md.tmpl index e7fe6f8c..14a6b474 100644 --- a/README.md.tmpl +++ b/README.md.tmpl @@ -13,16 +13,9 @@ Sponsored by [GolangCI.com](https://golangci.com): SaaS service for running lint * [Install](#install) * [Quick Start](#quick-start) * [Comparison](#comparison) - * [golangci-lint vs gometalinter](#golangci-lint-vs-gometalinter) - * [golangci-lint vs Run Needed Linters Manually](#golangci-lint-vs-run-needed-linters-manually) * [Performance](#performance) - * [Comparison with gometalinter](#comparison-with-gometalinter) * [Supported Linters](#supported-linters) - * [Enabled By Default Linters](#enabled-by-default-linters) - * [Disabled By Default Linters (-E/--enable)](#disabled-by-default-linters--e--enable) * [Configuration](#configuration) - * [Command-Line Options](#command-line-options) - * [Configuration File](#configuration-file) * [False Positives](#false-positives) * [IDE integrations](#ide-integrations) * [Internals](#internals) @@ -40,7 +33,26 @@ Short 1.5 min video demo of analyzing [beego](https://github.com/astaxie/beego). [![asciicast](https://asciinema.org/a/183662.png)](https://asciinema.org/a/183662) # Install -Recommended way to install is: +## CI Installation +The most installations are done for CI (travis, circleci etc). It's important to have reproducable CI: +don't start to fail all builds at one moment. With golangci-lint this can cappen if you +use `--enable-all` and new linter is added or even without `--enable-all`: when one linter +was upgraded from the upstream. + +Therefore it's highly recommended to install a fixed version of golangci-lint. +Find needed version on the [releases page](https://github.com/golangci/golangci-lint/releases). + +The recommended way to install golangci-lint is the next: +```bash +curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s VERSION +``` + +Periodically update version of golangci-lint: we do active development +and deliver a lot of improvements. But do it explicitly with checking of +newly found issues. + +## Local Installation +It's a not recommended for CI method. Do it only for the local development. ```bash go get -u github.com/golangci/golangci-lint/cmd/golangci-lint ``` @@ -48,16 +60,9 @@ go get -u github.com/golangci/golangci-lint/cmd/golangci-lint You can also install it by brew: ```bash brew install golangci/tap/golangci-lint +brew upgrade golangci/tap/golangci-lint ``` -For CI you can use fast local installation: -```bash -curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -``` - -Check the [releases page](https://github.com/golangci/golangci-lint/releases) to fix the version. - - # Quick Start To run golangci-lint execute: ```bash diff --git a/pkg/commands/executor.go b/pkg/commands/executor.go index 4b42395f..a52e572a 100644 --- a/pkg/commands/executor.go +++ b/pkg/commands/executor.go @@ -18,7 +18,10 @@ type Executor struct { func NewExecutor(version, commit, date string) *Executor { e := &Executor{ - cfg: &config.Config{}, + cfg: &config.Config{}, + version: version, + commit: commit, + date: date, } logrus.SetLevel(logrus.WarnLevel) @@ -27,10 +30,6 @@ func NewExecutor(version, commit, date string) *Executor { e.initRun() e.initLinters() - e.version = version - e.commit = commit - e.date = date - return e } diff --git a/pkg/commands/root.go b/pkg/commands/root.go index 19b8cedf..888385af 100644 --- a/pkg/commands/root.go +++ b/pkg/commands/root.go @@ -90,7 +90,7 @@ func (e *Executor) initRootFlagSet(fs *pflag.FlagSet) { fs.StringVar(&e.cfg.Run.CPUProfilePath, "cpu-profile-path", "", wh("Path to CPU profile output file")) fs.StringVar(&e.cfg.Run.MemProfilePath, "mem-profile-path", "", wh("Path to memory profile output file")) fs.IntVarP(&e.cfg.Run.Concurrency, "concurrency", "j", getDefaultConcurrency(), wh("Concurrency (default NumCPU)")) - if e.commit != "" { + if e.date != "" { fs.BoolVar(&e.cfg.Run.PrintVersion, "version", false, wh("Print version")) } }