Save 37% off PRO during our Black Friday Sale! »

go-critic

64a4ba69d50590e592cd8e572454daa8?s=47 Oleg Kovalov
September 25, 2018

 go-critic

64a4ba69d50590e592cd8e572454daa8?s=128

Oleg Kovalov

September 25, 2018
Tweet

Transcript

  1. Go-critic Static analysis in Go by Oleg Kovalov

  2. Why static analysis? - Better code - Human friendly -

    Optimal code Good examples: - golint - go vet - gometalinter - golangci-lint - go-critic
  3. Project status - 58 checks implemented + 54 in current

    todo - Optimistic merging (10+ contributors)
  4. Types of analysis - Diagnostics - Suspicious code - Code

    style - Can be more readable - Performance - Can be faster
  5. Diagnostic check: nilValReturn

  6. Code style check: namedConst

  7. Performance check: indexAlloc

  8. Go-toolsmith - astfmt - Print ast.Node with %s - astp

    - Predicates for AST nodes - astcopy - Deep copy for AST nodes - astequal - Deep equal for AST nodes - astinfo - Useful AST information - strparse - Parse string to AST Clickable link: github.com/go-toolsmith
  9. Demo: problem description - strings.Index("<long string>", "i") vs - strings.IndexByte("<long

    string>", 'i') BenchmarkIndex-4 100000000 19.3 ns/op BenchmarkIndexByte-4 100000000 16.4 ns/op
  10. Make a new rule - go get go-critic - make

    new <checker_name> - adding code examples (positive & negative) - copy-pasting coding - adding docs - git push - .... - PROFIT Code: https://bit.ly/2NDbOtV
  11. Trophies Our trophies collection: go-critic.github.io/trophies.html

  12. Thank you - github.com/go-critic/go-critic - github.com/go-toolsmith - twitter.com/oleg_kovalov - github.com/cristaloleg