https://www.testim.io/blog/what-is-a-linter-heres-a-definition-and-quick-start-guide/ linter上手完全指南 https://github.yanhaixiang.com/linter-tutorial/theory/history.html 让我们从定义什么是linter开始。正如您在简介中所读到的,linter是一种帮助您改进代码的工具。但它以什么方式做到这一点?答案是:通过分析源代码查找问题。 Linter 想要提示错误,那首先就得阅读代码,这也是为什么 Linter 也被称为 静态代码分析的工具。阅读完之后, 再加上我们人为自定义好的一些规则,那么 Linter 就拥有了提示错误的能力了。

注意:这里的错误是广义上的错误,比如语法错误、潜在 Bug、代码风格等,这些上报的错误是需要人设定规则的,如果你不设定也是可以的, 比如你也可以做一个只检查代码风格的 Linter。所以说,Linter 并不等于 Compiler。

linter一词来自一个最初称为“lint”的工具,它分析C源代码。1978年,计算机科学家斯蒂芬·C·约翰逊(Stephen C.Johnson)在贝尔实验室工作时开发了这一实用程序。

最初的lint工具以及早期的类似实用程序的目标都是分析源代码,以实现编译器优化。随着时间的推移,类似棉绒的工具开始添加许多其他类型的检查和验证

然而,正如我们在介绍中提到的,linters并不局限于编译语言。相反:我们可以说,**由于在开发期间没有编译器来检测错误,所以linters对于解释语言来说更有价值

golangci-lint

gofmt

gofmt --help
usage: gofmt [flags] [path ...]
  -cpuprofile string
        write cpu profile to this file
  -d    display diffs instead of rewriting files
  -e    report all errors (not just the first 10 on different lines)
  -l    list files whose formatting differs from gofmt's
  -r string
        rewrite rule (e.g., 'a[b:len(a)] -> a[b:]')
  -s    simplify code
  -w    write result to (source) file instead of stdout

yamlint

markdownlint

https://github.com/markdownlint/markdownlint