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
91
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
59
Enums - An introduction
tommymuehle
0
170
Defensive programming
tommymuehle
10
1.3k
Why setters are bad
tommymuehle
2
660
Keep yourself up to date
tommymuehle
0
200
Exception handling - classic and fancy
tommymuehle
3
560
Other Decks in Programming
See All in Programming
Vaporモードを大規模サービスに最速導入して学びを共有する
kazukishimamoto
4
4.3k
PLoP 2024: The evolution of the microservice architecture pattern language
cer
PRO
0
1.6k
Progressive Web Apps für Desktop und Mobile mit Angular (Hands-on)
christianliebel
PRO
0
110
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
110
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
150
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
100
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
16
4k
CSC509 Lecture 08
javiergs
PRO
0
110
Server Driven Compose With Firebase
skydoves
0
400
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
7
2.8k
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
350
qmuntal/stateless のススメ
sgash708
0
120
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
31
1.5k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
The Language of Interfaces
destraynor
154
24k
Faster Mobile Websites
deanohume
304
30k
Designing on Purpose - Digital PM Summit 2013
jponch
115
6.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
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