Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduce go-mnd
Search
Tommy Mühle
February 06, 2020
Programming
180
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduce go-mnd
Short introduction of go-mnd, the magic number detector for Go.
Tommy Mühle
February 06, 2020
More Decks by Tommy Mühle
See All by Tommy Mühle
Useful daily business packages
tommymuehle
1
140
Enums - An introduction
tommymuehle
0
300
Defensive programming
tommymuehle
10
1.4k
Why setters are bad
tommymuehle
2
790
Keep yourself up to date
tommymuehle
0
280
Exception handling - classic and fancy
tommymuehle
3
670
Other Decks in Programming
See All in Programming
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
410
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
150
act1-costs.pdf
sumedhbala
0
210
symfony/aiとlaravel/boost
77web
0
120
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
370
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
480
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
510
フィードバックで育てるAI開発
kotaminato
1
110
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
160
初めてのKubernetes 本番運用でハマった話
oku053
0
120
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
580
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
360
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
630
A Soul's Torment
seathinner
6
3.1k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
230
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Amusing Abliteration
ianozsvald
1
220
Game over? The fight for quality and originality in the time of robots
wayneb77
1
220
Become a Pro
speakerdeck
PRO
31
6k
Site-Speed That Sticks
csswizardry
13
1.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.3k
My Coaching Mixtape
mlcsv
0
170
Transcript
Tommy Mühle | tommy-muehle.io Tommy Mühle Software Engineer and Author
1
Tommy Mühle | tommy-muehle.io Introduce go-mnd 2
Tommy Mühle | tommy-muehle.io A vet analyzer to detect magic
numbers 3
Tommy Mühle | tommy-muehle.io Magic number? 4
Tommy Mühle | tommy-muehle.io Tommy Mühle | tommy-muehle.io A magic
number is a numeric literal that is not defined as a constant, but which may change, and therefore can be hard to update. 5
Tommy Mühle | tommy-muehle.io Hide intention 6
Tommy Mühle | tommy-muehle.io Hard to change 7
package main import `github.com/google/go-github/github` func main() { var repo github.Repository
// ... if repo.GetTeamID() == 12 { // ... } } Tommy Mühle | tommy-muehle.io 8
package main import `github.com/google/go-github/github` const TeamEngineering = 12 func main()
{ var repo github.Repository // ... if repo.GetTeamID() == TeamEngineering { // ... } } Tommy Mühle | tommy-muehle.io 9
Tommy Mühle | tommy-muehle.io How it works 10
Tommy Mühle | tommy-muehle.io 11 >= 1.12
Tommy Mühle | tommy-muehle.io Supported checks 12
package main import ( "net/http" "time" ) func main() {
client := &http.Client{ Timeout: 5 * time.Second, } // ... } Tommy Mühle | tommy-muehle.io 13 Assignment
Tommy Mühle | tommy-muehle.io 14 package main import ( "fmt"
"time" ) func main() { t := time.Now() switch { case t.Hour() < 12: fmt.Println("Good morning!") default: fmt.Println("Good evening.") } } Case
package main import "net/http" func handler(w http.ResponseWriter, r *http.Request) {
// ... http.Error(w, http.StatusText(404), 404) } Tommy Mühle | tommy-muehle.io 15 Argument
package main type queue struct { // ... } //
... func (q *queue) MaxLength() int { return 500 } Tommy Mühle | tommy-muehle.io 16 Return
package main func main() { var y int // ...
x := y * 100 // ... } Tommy Mühle | tommy-muehle.io 17 Operator
Tommy Mühle | tommy-muehle.io 18 package main func main() {
var x int // ... if x > 100 { // ... } } Condition
Tommy Mühle | tommy-muehle.io Demo 19
Tommy Mühle | tommy-muehle.io 20
Tommy Mühle | tommy-muehle.io 21
Tommy Mühle | tommy-muehle.io 22
Tommy Mühle | tommy-muehle.io 22
Questions?
Thank you! Slides http:/ /bit.ly/2pTywBB @tommy_muehle