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
100
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
680
Keep yourself up to date
tommymuehle
0
210
Exception handling - classic and fancy
tommymuehle
3
580
Other Decks in Programming
See All in Programming
ecspresso, ecschedule, lambroll を PipeCDプラグインとして動かしてみた (プロトタイプ) / Running ecspresso, ecschedule, and lambroll as PipeCD Plugins (prototype)
tkikuc
2
1.9k
週次リリースを実現するための グローバルアプリ開発
tera_ny
1
1.2k
Fixstars高速化コンテスト2024準優勝解法
eijirou
0
190
2025.01.17_Sansan × DMM.swift
riofujimon
2
560
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
13
2.3k
月刊 競技プログラミングをお仕事に役立てるには
terryu16
1
1.2k
カンファレンス動画鑑賞会のススメ / Osaka.swift #1
hironytic
0
170
Beyond ORM
77web
11
1.6k
Swiftコンパイラ超入門+async関数の仕組み
shiz
0
180
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
590
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
shadcn/uiを使ってReactでの開発を加速させよう!
lef237
0
300
Featured
See All Featured
Faster Mobile Websites
deanohume
305
30k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
98
18k
A Tale of Four Properties
chriscoyier
157
23k
Building Your Own Lightsaber
phodgson
104
6.2k
Unsuck your backbone
ammeep
669
57k
Making the Leap to Tech Lead
cromwellryan
133
9k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
500
Designing for humans not robots
tammielis
250
25k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
BBQ
matthewcrist
85
9.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
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