SlideShare a Scribd company logo
1 of 59
Download to read offline
Tools
bringing happiness
Code Inspection Tools
• gotype
• errcheck
• go vet
• golint
• defercheck, structcheck, varcheck
gotype
https://godoc.org/golang.org/x/tools/cmd/gotype
“syntactic and semantic analysis of Go files and
packages like the front-end of a Go compiler”
go get golang.org/x/tools/cmd/gotype
gotype
https://godoc.org/golang.org/x/tools/cmd/gotype
gotype
https://godoc.org/golang.org/x/tools/cmd/gotype
gotype
https://godoc.org/golang.org/x/tools/cmd/gotype
gotype
https://godoc.org/golang.org/x/tools/cmd/gotype
errcheck
https://github.com/kisielk/errcheck
“Errcheck is a program for checking for
unchecked errors in go programs”
go get github.com/kisielk/errcheck
errcheck
https://github.com/kisielk/errcheck
go vet
http://godoc.org/golang.org/x/tools/cmd/vet
“reports suspicious constructs”
go get golang.org/x/tools/cmd/vet
• Suspicious calls to functions in the Printf family
• Locks that are erroneously passed by value
• Unreachable code
• Shadowed variables
...
Comparisons between functions and nil
go vet
comparison of function
useless != nil is always true
Comparisons between functions and nil
go vet
unreachable code
Unreachable code
go vet
golint
https://github.com/golang/lint
“Golint makes suggestions for many of the
mechanically checkable items listed in Effective
Go and the CodeReviewComments wiki page.”
go get github.com/golang/lint/golint
golint
should replace x += 1 with x++
x++ and x--
golint
• error var SomeErr should have name of the form ErrFoo
• exported var SomeErr should have comment or be unexported
global error vars & doc comments
defercheck, structcheck, varcheck
https://github.com/opennota/check
• defercheck
Find repeating defers
• structcheck
Find unused struct fields
• varcheck
Find unused global variables and constants
go get github.com/opennota/check/cmd/...
SublimeLinter
https://github.com/SublimeLinter/SublimeLinter3
Sublime​Linter-contrib-gotype
https://packagecontrol.io/packages/SublimeLinter-contrib-gotype
SublimeLinter-contrib-govet
https://packagecontrol.io/packages/SublimeLinter-contrib-govet
SublimeLinter-contrib-golint
https://packagecontrol.io/packages/SublimeLinter-contrib-golint
SublimeLinter-contrib-errcheck
https://github.com/alecthomas/SublimeLinter-contrib-errcheck
SublimeLinter
https://github.com/SublimeLinter/SublimeLinter3
SublimeLinter
https://github.com/SublimeLinter/SublimeLinter3
Toggle Linter...
^⌘T
SublimeLinter
https://github.com/SublimeLinter/SublimeLinter3
Code Comprehension Tools
• godoc -analysis
https://golang.org/lib/godoc/analysis/help.html
• oracle
http://golang.org/s/oracle-user-manual
https://github.com/fzipp/pythia
godoc -analysis
https://golang.org/lib/godoc/analysis/help.html
$ godoc -http=:6060 -analysis=type,pointer
godoc -analysis
https://golang.org/lib/godoc/analysis/help.html
$ godoc -http=:6060 -analysis=type,pointer
godoc -analysis
https://golang.org/lib/godoc/analysis/help.html
$ godoc -http=:6060 -analysis=type,pointer
godoc -analysis
https://golang.org/lib/godoc/analysis/help.html
$ godoc -http=:6060 -analysis=type,pointer
godoc -analysis
https://golang.org/lib/godoc/analysis/help.html
$ godoc -http=:6060 -analysis=type,pointer
godoc -analysis
https://golang.org/lib/godoc/analysis/help.html
$ godoc -http=:6060 -analysis=type,pointer
oracle
http://golang.org/s/oracle-user-manual
go get golang.org/x/tools/cmd/oracle
$ oracle 
-pos='./src/github.com/boltdb/bolt/tx.go:#1630' 
-format=plain 
callers github.com/boltdb/bolt
./src/github.com/boltdb/bolt/tx.go:66:15: (*github.com/boltdb/bolt.Tx).
Size is called from these 1 sites:
./src/github.com/boltdb/bolt/tx.go:285:35: static method call from
(*github.com/boltdb/bolt.Tx).WriteTo
oracle + pythia
https://github.com/fzipp/pythia
$ pythia -v github.com/boltdb/bolt/cmd/bolt github.com/boltdb/bolt
go get github.com/fzipp/pythia
Refactoring Tools
• gorename
• gofmt -r
• ed
gorename
https://godoc.org/golang.org/x/tools/cmd/gorename
“The gorename command performs precise type-safe
renaming of identifiers in Go source code.”
go get golang.org/x/tools/cmd/oracle
$ gorename -v -from='"demo".handler' -to='rootHandler'❚
$ gorename -v -from='"demo".handler' -to='rootHandler'
Renamed 2 occurrences in 1 file in 1 package.
$ ❚
gofmt -r
https://golang.org/cmd/gofmt/
“Apply the rewrite rule to the source before reformatting”
$ gofmt -w -r 'x.Write([]byte(y)) -> x.Write([]byte(strings.ToLower
(y)))' src/demo/main.go ❚
$ gofmt -w -r 'x.Write([]byte(y)) -> x.Write([]byte(strings.ToLower
(y)))' src/demo/main.go
$ ❚
$ gofmt -w -r 'http.ListenAndServe(x, y) ->
http.ListenAndServe(x, y, "BAD THING")' src/demo/main.go ❚
$ gofmt -w -r 'http.ListenAndServe(x, y) ->
http.ListenAndServe(x, y, "BAD THING")' src/demo/main.go
$ ❚
eg
“Example-based refactoring of expressions...”
go get golang.org/x/tools/cmd/eg
1
2
3
5
$ eg -w -t eg-template.go demo ❚
6
$ eg -w -t eg-template.go demo
=== eg/src/demo/demo.go (1 matches)
$ ❚
7
$ eg -w -t eg-template.go demo
=== eg/src/demo/demo.go (1 matches)
$ gorename -from='"demo".NewPoint' -to='NewPoint__OLD__' ❚
8
$ eg -w -t eg-template.go demo
=== eg/src/demo/demo.go (1 matches)
$ gorename -from='"demo".NewPoint' -to='NewPoint__OLD__'
$ ❚
9
$ eg -w -t eg-template.go demo
=== eg/src/demo/demo.go (1 matches)
$ gorename -from='"demo".NewPoint' -to='NewPoint__OLD__'
$ gorename -from='"demo".NewPoint__NEW__' -to='NewPoint' ❚
10
$ eg -w -t eg-template.go demo
=== eg/src/demo/demo.go (1 matches)
$ gorename -from='"demo".NewPoint' -to='NewPoint__OLD__'
$ gorename -from='"demo".NewPoint__NEW__' -to='NewPoint'
$ ❚
gocyclo
https://github.com/fzipp/gocyclo
“calculates cyclomatic complexities of
functions”
1 is the base complexity of a function
+1 for each 'if', 'for', 'case', '&&' or '||'
MOAR TOOLZ
• https://godoc.org/golang.org/x/tools
• https://github.com/golang/tools/tree/master/cmd
• http://dominik.honnef.co/posts/2014/12/an_incomplete_list_of_go_tools/
package main
import "fmt"
func main() {
contact := struct {
name, email string
}{
"Konstantin Cherkasov",
"k.cherkasoff@gmail.com",
}
fmt.Println(contact)
}

More Related Content

What's hot

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 

What's hot (20)

Git real slides
Git real slidesGit real slides
Git real slides
 
DevOpsDays PDX - Batteries Included: Enabling Community Contribution
DevOpsDays PDX - Batteries Included: Enabling Community ContributionDevOpsDays PDX - Batteries Included: Enabling Community Contribution
DevOpsDays PDX - Batteries Included: Enabling Community Contribution
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
Juliette Reinders Folmer - Promote your open source project with GitHub Pages...
 
Collaborative Development: The Only CD That Matters - Brent Beer - Codemotion...
Collaborative Development: The Only CD That Matters - Brent Beer - Codemotion...Collaborative Development: The Only CD That Matters - Brent Beer - Codemotion...
Collaborative Development: The Only CD That Matters - Brent Beer - Codemotion...
 
Secure Programming Practices in C++ (NDC Oslo 2018)
Secure Programming Practices in C++ (NDC Oslo 2018)Secure Programming Practices in C++ (NDC Oslo 2018)
Secure Programming Practices in C++ (NDC Oslo 2018)
 
C++ The Principles of Most Surprise
C++ The Principles of Most SurpriseC++ The Principles of Most Surprise
C++ The Principles of Most Surprise
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
C++ for Java Developers (JavaZone Academy 2018)
C++ for Java Developers (JavaZone Academy 2018)C++ for Java Developers (JavaZone Academy 2018)
C++ for Java Developers (JavaZone Academy 2018)
 
Geb for browser automation
Geb for browser automationGeb for browser automation
Geb for browser automation
 
Git Real
Git RealGit Real
Git Real
 
Trying to learn C# (NDC Oslo 2019)
Trying to learn C# (NDC Oslo 2019)Trying to learn C# (NDC Oslo 2019)
Trying to learn C# (NDC Oslo 2019)
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Github
GithubGithub
Github
 
Essential Git and Github commands
Essential Git and Github commandsEssential Git and Github commands
Essential Git and Github commands
 
Monitoring using Sensu
Monitoring using SensuMonitoring using Sensu
Monitoring using Sensu
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
 
Continuous Delivery As Code
Continuous Delivery As CodeContinuous Delivery As Code
Continuous Delivery As Code
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
 
Docker Testing
Docker TestingDocker Testing
Docker Testing
 

Similar to Tools Bringing Happiness

Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexy
Ailsa126
 
SECON'2017, Цаль-Цалко Иван, Go на практике
SECON'2017, Цаль-Цалко Иван, Go на практикеSECON'2017, Цаль-Цалко Иван, Go на практике
SECON'2017, Цаль-Цалко Иван, Go на практике
SECON
 

Similar to Tools Bringing Happiness (20)

Goの標準的な開発の流れ
Goの標準的な開発の流れGoの標準的な開発の流れ
Goの標準的な開発の流れ
 
Intro. to Git and Github
Intro. to Git and GithubIntro. to Git and Github
Intro. to Git and Github
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目goaを使った開発TIPS@六本木一丁目
goaを使った開発TIPS@六本木一丁目
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexy
 
Productivity tips for developers
Productivity tips for developersProductivity tips for developers
Productivity tips for developers
 
Git::Hooks
Git::HooksGit::Hooks
Git::Hooks
 
Mr.Crabs Git workflow
Mr.Crabs Git workflowMr.Crabs Git workflow
Mr.Crabs Git workflow
 
Github basics
Github basicsGithub basics
Github basics
 
Grooscript gr8conf 2015
Grooscript gr8conf 2015Grooscript gr8conf 2015
Grooscript gr8conf 2015
 
SECON'2017, Цаль-Цалко Иван, Go на практике
SECON'2017, Цаль-Цалко Иван, Go на практикеSECON'2017, Цаль-Цалко Иван, Go на практике
SECON'2017, Цаль-Цалко Иван, Go на практике
 
Git - Some tips to do it better
Git - Some tips to do it betterGit - Some tips to do it better
Git - Some tips to do it better
 
How to install and use git
How to install and  use gitHow to install and  use git
How to install and use git
 
DWX 2022 - DevSecOps mit GitHub
DWX 2022 - DevSecOps mit GitHubDWX 2022 - DevSecOps mit GitHub
DWX 2022 - DevSecOps mit GitHub
 
コードジェネレートとの付き合い方 @Go Conference 2018 Spring
コードジェネレートとの付き合い方 @Go Conference 2018 Springコードジェネレートとの付き合い方 @Go Conference 2018 Spring
コードジェネレートとの付き合い方 @Go Conference 2018 Spring
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
LetSwift 2017 - 토스 iOS 앱의 개발/배포 환경
LetSwift 2017 - 토스 iOS 앱의 개발/배포 환경LetSwift 2017 - 토스 iOS 앱의 개발/배포 환경
LetSwift 2017 - 토스 iOS 앱의 개발/배포 환경
 
Git within RStudio
Git within RStudioGit within RStudio
Git within RStudio
 
CVPR2017 oral survey
CVPR2017 oral surveyCVPR2017 oral survey
CVPR2017 oral survey
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Recently uploaded (20)

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

Tools Bringing Happiness