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
0
96
Introduce go-mnd
Short introduction of go-mnd, the magic number detector for Go.
Tommy Mühle
February 06, 2020
Tweet
Share
More Decks by Tommy Mühle
See All by Tommy Mühle
Useful daily business packages
tommymuehle
1
63
Enums - An introduction
tommymuehle
0
180
Defensive programming
tommymuehle
10
1.3k
Why setters are bad
tommymuehle
2
670
Keep yourself up to date
tommymuehle
0
210
Exception handling - classic and fancy
tommymuehle
3
570
Other Decks in Programming
See All in Programming
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
Beyond ORM
77web
3
410
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
nekko cloudにおけるProxmox VE利用事例
irumaru
3
420
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
710
testcontainers のススメ
sgash708
1
120
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
1
140
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
Featured
See All Featured
Building Adaptive Systems
keathley
38
2.3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
GraphQLとの向き合い方2022年版
quramy
44
13k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Become a Pro
speakerdeck
PRO
26
5k
Being A Developer After 40
akosma
87
590k
Unsuck your backbone
ammeep
669
57k
Docker and Python
trallard
42
3.1k
A designer walks into a library…
pauljervisheath
204
24k
How to Ace a Technical Interview
jacobian
276
23k
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