dev: discourage bad practices (#803)
This commit is contained in:
		
							parent
							
								
									7004896cab
								
							
						
					
					
						commit
						ca6effbeec
					
				
							
								
								
									
										44
									
								
								.github/ISSUE_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										44
									
								
								.github/ISSUE_TEMPLATE.md
									
									
									
									
										vendored
									
									
								
							| @ -1,7 +1,43 @@ | ||||
| Thank you for creating the issue! | ||||
| 
 | ||||
| - [ ] Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported. | ||||
| - [ ] Yes, I've searched similar issues on GitHub and didn't find any. | ||||
| - [ ] Yes, I've included all information below (version, config, etc). | ||||
| 
 | ||||
| Please include the following information: | ||||
| 1. Version of golangci-lint: `golangci-lint --version` (or git commit if you don't use binary distribution) | ||||
| 2. Config file: `cat .golangci.yml` | ||||
| 3. Go environment: `go version && go env` | ||||
| 4. Verbose output of running: `golangci-lint run -v` | ||||
| 
 | ||||
| <details><summary>Version of golangci-lint</summary> | ||||
| 
 | ||||
| ```bash | ||||
| $ golangci-lint --version | ||||
| # paste output here | ||||
| ``` | ||||
| 
 | ||||
| </details> | ||||
| 
 | ||||
| <details><summary>Config file</summary> | ||||
| 
 | ||||
| ```bash | ||||
| $ cat .golangci.yml | ||||
| # paste output here | ||||
| ``` | ||||
| 
 | ||||
| </details> | ||||
| 
 | ||||
| <details><summary>Go environment</summary> | ||||
| 
 | ||||
| ```bash | ||||
| $ go version && go env | ||||
| # paste output here | ||||
| ``` | ||||
| 
 | ||||
| </details> | ||||
| 
 | ||||
| <details><summary>Verbose output of running</summary> | ||||
| 
 | ||||
| ```bash | ||||
| $ golangci-lint run -v | ||||
| # paste output here | ||||
| ``` | ||||
| 
 | ||||
| </details> | ||||
|  | ||||
| @ -225,7 +225,6 @@ linters: | ||||
|   enable: | ||||
|     - megacheck | ||||
|     - govet | ||||
|   enable-all: false | ||||
|   disable: | ||||
|     - maligned | ||||
|     - prealloc | ||||
|  | ||||
| @ -48,6 +48,7 @@ linters-settings: | ||||
|     statements: 50 | ||||
| 
 | ||||
| linters: | ||||
|   # please, do not use `enable-all`: it's deprecated and will be removed soon. | ||||
|   # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint | ||||
|   disable-all: true | ||||
|   enable: | ||||
|  | ||||
							
								
								
									
										110
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										110
									
								
								README.md
									
									
									
									
									
								
							| @ -14,24 +14,42 @@ Sponsored by [GolangCI.com](https://golangci.com): SaaS service for running lint | ||||
| 
 | ||||
| <a href="https://golangci.com/"><img src="docs/go.png" width="250px"></a> | ||||
| 
 | ||||
| * [Demo](#demo) | ||||
| * [Install](#install) | ||||
| * [Trusted By](#trusted-by) | ||||
| * [Quick Start](#quick-start) | ||||
| * [Editor Integration](#editor-integration) | ||||
| * [Shell Completion](#shell-completion) | ||||
| * [Comparison](#comparison) | ||||
| * [Performance](#performance) | ||||
| * [Internals](#internals) | ||||
| * [Supported Linters](#supported-linters) | ||||
| * [Configuration](#configuration) | ||||
| * [False Positives](#false-positives) | ||||
| * [FAQ](#faq) | ||||
| * [Thanks](#thanks) | ||||
| * [Changelog](#changelog) | ||||
| * [Debug](#debug) | ||||
| * [Future Plans](#future-plans) | ||||
| * [Contact Information](#contact-information) | ||||
| - [GolangCI-Lint](#golangci-lint) | ||||
|   - [Demo](#demo) | ||||
|   - [Install](#install) | ||||
|     - [Binary Release](#binary-release) | ||||
|     - [MacOS](#macos) | ||||
|     - [By Docker](#by-docker) | ||||
|     - [go get](#go-get) | ||||
|   - [Trusted By](#trusted-by) | ||||
|   - [Quick Start](#quick-start) | ||||
|   - [Editor Integration](#editor-integration) | ||||
|   - [Shell Completion](#shell-completion) | ||||
|     - [Mac OS X](#mac-os-x) | ||||
|     - [Linux](#linux) | ||||
|   - [Comparison](#comparison) | ||||
|     - [`golangci-lint` vs `gometalinter`](#golangci-lint-vs-gometalinter) | ||||
|     - [`golangci-lint` vs Running Linters Manually](#golangci-lint-vs-running-linters-manually) | ||||
|   - [Performance](#performance) | ||||
|     - [Comparison with gometalinter](#comparison-with-gometalinter) | ||||
|     - [Why golangci-lint is faster](#why-golangci-lint-is-faster) | ||||
|     - [Memory Usage of Golangci-lint](#memory-usage-of-golangci-lint) | ||||
|   - [Internals](#internals) | ||||
|   - [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) | ||||
|     - [Config File](#config-file) | ||||
|   - [False Positives](#false-positives) | ||||
|     - [Nolint](#nolint) | ||||
|   - [FAQ](#faq) | ||||
|   - [Thanks](#thanks) | ||||
|   - [Changelog](#changelog) | ||||
|   - [Debug](#debug) | ||||
|   - [Future Plans](#future-plans) | ||||
|   - [Contact Information](#contact-information) | ||||
|   - [License Scan](#license-scan) | ||||
| 
 | ||||
| ## Demo | ||||
| 
 | ||||
| @ -44,28 +62,28 @@ Short 1.5 min video demo of analyzing [beego](https://github.com/astaxie/beego). | ||||
| 
 | ||||
| ## Install | ||||
| 
 | ||||
| ### CI Installation | ||||
| ### Binary Release | ||||
| 
 | ||||
| Most installations are done for CI (travis, circleci etc). It's important to have reproducible CI: | ||||
| don't start to fail all builds at the same time. With golangci-lint this can happen if you | ||||
| use `--enable-all` and a new linter is added or even without `--enable-all`: when one upstream linter is upgraded. | ||||
| use deprecated option `--enable-all` and a new linter is added or even without `--enable-all`: when one upstream linter is upgraded. | ||||
| 
 | ||||
| It's highly recommended to install a fixed version of golangci-lint. | ||||
| Releases are available on the [releases page](https://github.com/golangci/golangci-lint/releases). | ||||
| 
 | ||||
| Latest version:  | ||||
| Latest version: [v1.20.0](https://github.com/golangci/golangci-lint/releases/tag/v1.20.0) | ||||
| 
 | ||||
| Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version): | ||||
| Here is the recommended way to install golangci-lint: | ||||
| 
 | ||||
| ```bash | ||||
| # binary will be $(go env GOPATH)/bin/golangci-lint | ||||
| curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin vX.Y.Z | ||||
| curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.20.0 | ||||
| 
 | ||||
| # or install it into ./bin/ | ||||
| curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s vX.Y.Z | ||||
| curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.20.0 | ||||
| 
 | ||||
| # In alpine linux (as it does not come with curl by default) | ||||
| wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s vX.Y.Z | ||||
| wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.20.0 | ||||
| 
 | ||||
| golangci-lint --version | ||||
| ``` | ||||
| @ -74,41 +92,30 @@ Periodically update version of golangci-lint: the project is under active develo | ||||
| and is constantly being improved. But please always check for newly found issues and | ||||
| update if needed. | ||||
| 
 | ||||
| ### Local Installation | ||||
| ### MacOS | ||||
| 
 | ||||
| Local installation is not recommended for your CI pipeline. Only install the linter this way in a local development environment. | ||||
| 
 | ||||
| #### Windows, MacOS and Linux | ||||
| 
 | ||||
| ```bash | ||||
| go get -u github.com/golangci/golangci-lint/cmd/golangci-lint | ||||
| ``` | ||||
| 
 | ||||
| With `go1.12` or later you can get a particular version | ||||
| 
 | ||||
| ```bash | ||||
| GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.18.0 | ||||
| ``` | ||||
| 
 | ||||
| #### MacOS | ||||
| 
 | ||||
| You can also install it on MacOS using [brew](https://brew.sh/): | ||||
| You can also install a binary release on MacOS using [brew](https://brew.sh/): | ||||
| 
 | ||||
| ```bash | ||||
| brew install golangci/tap/golangci-lint | ||||
| brew upgrade golangci/tap/golangci-lint | ||||
| ``` | ||||
| 
 | ||||
| #### `--version` | ||||
| 
 | ||||
| If you need your local `golangci-lint --version` to show proper version additionally run: | ||||
| ### By Docker | ||||
| 
 | ||||
| ```bash | ||||
| cd $(go env GOPATH)/src/github.com/golangci/golangci-lint/cmd/golangci-lint | ||||
| go install -ldflags "-X 'main.version=$(git describe --tags)' -X 'main.commit=$(git rev-parse --short HEAD)' -X 'main.date=$(date)'" | ||||
| docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.20.0 golangci-lint run -v | ||||
| ``` | ||||
| 
 | ||||
| On Windows, you can run the above commands with Git Bash, which comes with [Git for Windows](https://git-scm.com/download/win). | ||||
| ### go get | ||||
| 
 | ||||
| Please, do not install `golangci-lint` by `go get`: | ||||
| 
 | ||||
| 1. [`go.mod`](https://github.com/golangci/golangci-lint/blob/master/go.mod) replacement directive doesn't apply. It means you will be using patched version of `golangci-lint`. | ||||
| 2. it's much slower than binary installation | ||||
| 3. it's stability depends on your Go version (e.g. on [this compiler Go <= 1.12 bug](https://github.com/golang/go/issues/29612)). | ||||
| 4. it's not guaranteed to work: e.g. we've encountered a lot of issues with Go modules hashes. | ||||
| 5. it allows installation from `master` branch which can't be considered stable. | ||||
| 
 | ||||
| ## Trusted By | ||||
| 
 | ||||
| @ -515,7 +522,6 @@ Flags: | ||||
|       --skip-files strings          Regexps of files to skip | ||||
|   -E, --enable strings              Enable specific linter | ||||
|   -D, --disable strings             Disable specific linter | ||||
|       --enable-all                  Enable all linters | ||||
|       --disable-all                 Disable all linters | ||||
|   -p, --presets strings             Enable presets (bugs|complexity|format|performance|style|unused) of linters. Run 'golangci-lint linters' to see them. This option implies option --disable-all | ||||
|       --fast                        Run only fast linters from enabled linters set (first run won't be fast) | ||||
| @ -818,7 +824,6 @@ linters: | ||||
|   enable: | ||||
|     - megacheck | ||||
|     - govet | ||||
|   enable-all: false | ||||
|   disable: | ||||
|     - maligned | ||||
|     - prealloc | ||||
| @ -945,6 +950,7 @@ linters-settings: | ||||
|     statements: 50 | ||||
| 
 | ||||
| linters: | ||||
|   # please, do not use `enable-all`: it's deprecated and will be removed soon. | ||||
|   # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint | ||||
|   disable-all: true | ||||
|   enable: | ||||
| @ -1097,7 +1103,7 @@ Long answer: | ||||
| 
 | ||||
| **`golangci-lint` doesn't work** | ||||
| 
 | ||||
| 1. Update it: `go get -u github.com/golangci/golangci-lint/cmd/golangci-lint` | ||||
| 1. Please, ensure you are using the latest binary release. | ||||
| 2. Run it with `-v` option and check the output. | ||||
| 3. If it doesn't help create a [GitHub issue](https://github.com/golangci/golangci-lint/issues/new) with the output from the error and #2 above. | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										107
									
								
								README.tmpl.md
									
									
									
									
									
								
							
							
						
						
									
										107
									
								
								README.tmpl.md
									
									
									
									
									
								
							| @ -14,24 +14,42 @@ Sponsored by [GolangCI.com](https://golangci.com): SaaS service for running lint | ||||
| 
 | ||||
| <a href="https://golangci.com/"><img src="docs/go.png" width="250px"></a> | ||||
| 
 | ||||
| * [Demo](#demo) | ||||
| * [Install](#install) | ||||
| * [Trusted By](#trusted-by) | ||||
| * [Quick Start](#quick-start) | ||||
| * [Editor Integration](#editor-integration) | ||||
| * [Shell Completion](#shell-completion) | ||||
| * [Comparison](#comparison) | ||||
| * [Performance](#performance) | ||||
| * [Internals](#internals) | ||||
| * [Supported Linters](#supported-linters) | ||||
| * [Configuration](#configuration) | ||||
| * [False Positives](#false-positives) | ||||
| * [FAQ](#faq) | ||||
| * [Thanks](#thanks) | ||||
| * [Changelog](#changelog) | ||||
| * [Debug](#debug) | ||||
| * [Future Plans](#future-plans) | ||||
| * [Contact Information](#contact-information) | ||||
| - [GolangCI-Lint](#golangci-lint) | ||||
|   - [Demo](#demo) | ||||
|   - [Install](#install) | ||||
|     - [Binary Release](#binary-release) | ||||
|     - [MacOS](#macos) | ||||
|     - [By Docker](#by-docker) | ||||
|     - [go get](#go-get) | ||||
|   - [Trusted By](#trusted-by) | ||||
|   - [Quick Start](#quick-start) | ||||
|   - [Editor Integration](#editor-integration) | ||||
|   - [Shell Completion](#shell-completion) | ||||
|     - [Mac OS X](#mac-os-x) | ||||
|     - [Linux](#linux) | ||||
|   - [Comparison](#comparison) | ||||
|     - [`golangci-lint` vs `gometalinter`](#golangci-lint-vs-gometalinter) | ||||
|     - [`golangci-lint` vs Running Linters Manually](#golangci-lint-vs-running-linters-manually) | ||||
|   - [Performance](#performance) | ||||
|     - [Comparison with gometalinter](#comparison-with-gometalinter) | ||||
|     - [Why golangci-lint is faster](#why-golangci-lint-is-faster) | ||||
|     - [Memory Usage of Golangci-lint](#memory-usage-of-golangci-lint) | ||||
|   - [Internals](#internals) | ||||
|   - [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) | ||||
|     - [Config File](#config-file) | ||||
|   - [False Positives](#false-positives) | ||||
|     - [Nolint](#nolint) | ||||
|   - [FAQ](#faq) | ||||
|   - [Thanks](#thanks) | ||||
|   - [Changelog](#changelog) | ||||
|   - [Debug](#debug) | ||||
|   - [Future Plans](#future-plans) | ||||
|   - [Contact Information](#contact-information) | ||||
|   - [License Scan](#license-scan) | ||||
| 
 | ||||
| ## Demo | ||||
| 
 | ||||
| @ -44,28 +62,28 @@ Short 1.5 min video demo of analyzing [beego](https://github.com/astaxie/beego). | ||||
| 
 | ||||
| ## Install | ||||
| 
 | ||||
| ### CI Installation | ||||
| ### Binary Release | ||||
| 
 | ||||
| Most installations are done for CI (travis, circleci etc). It's important to have reproducible CI: | ||||
| don't start to fail all builds at the same time. With golangci-lint this can happen if you | ||||
| use `--enable-all` and a new linter is added or even without `--enable-all`: when one upstream linter is upgraded. | ||||
| use deprecated option `--enable-all` and a new linter is added or even without `--enable-all`: when one upstream linter is upgraded. | ||||
| 
 | ||||
| It's highly recommended to install a fixed version of golangci-lint. | ||||
| Releases are available on the [releases page](https://github.com/golangci/golangci-lint/releases). | ||||
| 
 | ||||
| Latest version:  | ||||
| Latest version: [{{.LatestVersion}}](https://github.com/golangci/golangci-lint/releases/tag/{{.LatestVersion}}) | ||||
| 
 | ||||
| Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version): | ||||
| Here is the recommended way to install golangci-lint: | ||||
| 
 | ||||
| ```bash | ||||
| # binary will be $(go env GOPATH)/bin/golangci-lint | ||||
| curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin vX.Y.Z | ||||
| curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin {{.LatestVersion}} | ||||
| 
 | ||||
| # or install it into ./bin/ | ||||
| curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s vX.Y.Z | ||||
| curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s {{.LatestVersion}} | ||||
| 
 | ||||
| # In alpine linux (as it does not come with curl by default) | ||||
| wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s vX.Y.Z | ||||
| wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s {{.LatestVersion}} | ||||
| 
 | ||||
| golangci-lint --version | ||||
| ``` | ||||
| @ -74,41 +92,30 @@ Periodically update version of golangci-lint: the project is under active develo | ||||
| and is constantly being improved. But please always check for newly found issues and | ||||
| update if needed. | ||||
| 
 | ||||
| ### Local Installation | ||||
| ### MacOS | ||||
| 
 | ||||
| Local installation is not recommended for your CI pipeline. Only install the linter this way in a local development environment. | ||||
| 
 | ||||
| #### Windows, MacOS and Linux | ||||
| 
 | ||||
| ```bash | ||||
| go get -u github.com/golangci/golangci-lint/cmd/golangci-lint | ||||
| ``` | ||||
| 
 | ||||
| With `go1.12` or later you can get a particular version | ||||
| 
 | ||||
| ```bash | ||||
| GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.18.0 | ||||
| ``` | ||||
| 
 | ||||
| #### MacOS | ||||
| 
 | ||||
| You can also install it on MacOS using [brew](https://brew.sh/): | ||||
| You can also install a binary release on MacOS using [brew](https://brew.sh/): | ||||
| 
 | ||||
| ```bash | ||||
| brew install golangci/tap/golangci-lint | ||||
| brew upgrade golangci/tap/golangci-lint | ||||
| ``` | ||||
| 
 | ||||
| #### `--version` | ||||
| 
 | ||||
| If you need your local `golangci-lint --version` to show proper version additionally run: | ||||
| ### By Docker | ||||
| 
 | ||||
| ```bash | ||||
| cd $(go env GOPATH)/src/github.com/golangci/golangci-lint/cmd/golangci-lint | ||||
| go install -ldflags "-X 'main.version=$(git describe --tags)' -X 'main.commit=$(git rev-parse --short HEAD)' -X 'main.date=$(date)'" | ||||
| docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:{{.LatestVersion}} golangci-lint run -v | ||||
| ``` | ||||
| 
 | ||||
| On Windows, you can run the above commands with Git Bash, which comes with [Git for Windows](https://git-scm.com/download/win). | ||||
| ### go get | ||||
| 
 | ||||
| Please, do not install `golangci-lint` by `go get`: | ||||
| 
 | ||||
| 1. [`go.mod`](https://github.com/golangci/golangci-lint/blob/master/go.mod) replacement directive doesn't apply. It means you will be using patched version of `golangci-lint`. | ||||
| 2. it's much slower than binary installation | ||||
| 3. it's stability depends on your Go version (e.g. on [this compiler Go <= 1.12 bug](https://github.com/golang/go/issues/29612)). | ||||
| 4. it's not guaranteed to work: e.g. we've encountered a lot of issues with Go modules hashes. | ||||
| 5. it allows installation from `master` branch which can't be considered stable. | ||||
| 
 | ||||
| ## Trusted By | ||||
| 
 | ||||
| @ -542,7 +549,7 @@ Long answer: | ||||
| 
 | ||||
| **`golangci-lint` doesn't work** | ||||
| 
 | ||||
| 1. Update it: `go get -u github.com/golangci/golangci-lint/cmd/golangci-lint` | ||||
| 1. Please, ensure you are using the latest binary release. | ||||
| 2. Run it with `-v` option and check the output. | ||||
| 3. If it doesn't help create a [GitHub issue](https://github.com/golangci/golangci-lint/issues/new) with the output from the error and #2 above. | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										3
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								go.mod
									
									
									
									
									
								
							| @ -40,7 +40,7 @@ require ( | ||||
| 	github.com/ultraware/whitespace v0.0.4 | ||||
| 	github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517 | ||||
| 	github.com/valyala/quicktemplate v1.2.0 | ||||
| 	golang.org/x/tools v0.0.0-20190930201159-7c411dea38b0 | ||||
| 	golang.org/x/tools v0.0.0-20191010075000-0337d82405ff | ||||
| 	gopkg.in/yaml.v2 v2.2.4 | ||||
| 	honnef.co/go/tools v0.0.1-2019.2.3 | ||||
| 	mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed | ||||
| @ -50,5 +50,4 @@ require ( | ||||
| 
 | ||||
| // https://github.com/golang/tools/pull/156 | ||||
| // https://github.com/golang/tools/pull/160 | ||||
| // https://github.com/golang/tools/pull/162 | ||||
| replace golang.org/x/tools => github.com/golangci/tools v0.0.0-20190915081525-6aa350649b1c | ||||
|  | ||||
| @ -166,6 +166,11 @@ func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, is | ||||
| 	fs.StringSliceVarP(&lc.Enable, "enable", "E", nil, wh("Enable specific linter")) | ||||
| 	fs.StringSliceVarP(&lc.Disable, "disable", "D", nil, wh("Disable specific linter")) | ||||
| 	fs.BoolVar(&lc.EnableAll, "enable-all", false, wh("Enable all linters")) | ||||
| 	if err := fs.MarkHidden("enable-all"); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	// TODO: run hideFlag("enable-all") to print deprecation message. | ||||
| 
 | ||||
| 	fs.BoolVar(&lc.DisableAll, "disable-all", false, wh("Disable all linters")) | ||||
| 	fs.StringSliceVarP(&lc.Presets, "presets", "p", nil, | ||||
| 		wh(fmt.Sprintf("Enable presets (%s) of linters. Run 'golangci-lint linters' to see "+ | ||||
|  | ||||
| @ -42,6 +42,16 @@ func genReadme(tmplPath, outPath string) error { | ||||
| 	return tmpl.Execute(out, ctx) | ||||
| } | ||||
| 
 | ||||
| func getLatestVersion() (string, error) { | ||||
| 	out, err := exec.Command("git", "tag", "-l", "--sort=-v:refname").Output() | ||||
| 	if err != nil { | ||||
| 		return "", fmt.Errorf("failed to run git tag: %w", err) | ||||
| 	} | ||||
| 
 | ||||
| 	lines := bytes.Split(out, []byte("\n")) | ||||
| 	return string(lines[0]), nil | ||||
| } | ||||
| 
 | ||||
| func buildTemplateContext() (map[string]interface{}, error) { | ||||
| 	golangciYaml, err := ioutil.ReadFile(".golangci.yml") | ||||
| 	if err != nil { | ||||
| @ -79,6 +89,11 @@ func buildTemplateContext() (map[string]interface{}, error) { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	latestVersion, err := getLatestVersion() | ||||
| 	if err != nil { | ||||
| 		return nil, fmt.Errorf("failed to get latest version: %w", err) | ||||
| 	} | ||||
| 
 | ||||
| 	return map[string]interface{}{ | ||||
| 		"GolangciYaml":                     strings.TrimSpace(string(golangciYaml)), | ||||
| 		"GolangciYamlExample":              strings.TrimSpace(string(golangciYamlExample)), | ||||
| @ -89,6 +104,7 @@ func buildTemplateContext() (map[string]interface{}, error) { | ||||
| 		"ThanksList":                       getThanksList(), | ||||
| 		"RunHelpText":                      string(shortHelp), | ||||
| 		"ChangeLog":                        string(changeLog), | ||||
| 		"LatestVersion":                    latestVersion, | ||||
| 	}, nil | ||||
| } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										2
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							| @ -185,7 +185,7 @@ golang.org/x/sys/windows | ||||
| golang.org/x/text/transform | ||||
| golang.org/x/text/unicode/norm | ||||
| golang.org/x/text/width | ||||
| # golang.org/x/tools v0.0.0-20190930201159-7c411dea38b0 => github.com/golangci/tools v0.0.0-20190915081525-6aa350649b1c | ||||
| # golang.org/x/tools v0.0.0-20191010075000-0337d82405ff => github.com/golangci/tools v0.0.0-20190915081525-6aa350649b1c | ||||
| golang.org/x/tools/go/analysis | ||||
| golang.org/x/tools/go/analysis/passes/asmdecl | ||||
| golang.org/x/tools/go/analysis/passes/assign | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Isaev Denis
						Isaev Denis