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
88
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
160
Defensive programming
tommymuehle
10
1.2k
Why setters are bad
tommymuehle
2
650
Keep yourself up to date
tommymuehle
0
200
Exception handling - classic and fancy
tommymuehle
3
540
Other Decks in Programming
See All in Programming
Increased Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
430
GraphQL あるいは React における自律的なデータ取得について
quramy
11
3k
なぜアジャイルがうまくいかないのか?
yum3
1
110
GoのIteratorに詳しくなってしまう
inatonix
1
210
Jakarta EE meets AI
ivargrimstad
0
390
状態管理ライブラリZustandの導入から運用まで
k1tikurisu
3
470
Modern Angular with the NGRX Signal Store New Rules for Your Architecture @BASTA! 2024 in Mainz
manfredsteyer
PRO
0
170
Amazon Neptuneで始める初めてのグラフDB ー グラフDBを使う意味を考える ー
satoshi256kbyte
2
260
Data Contracts In Practice With Debezium and Apache Flink
gunnarmorling
0
110
私のEbitengineの第一歩
qt_luigi
0
450
Ebitengineの1vs1ゲーム WebRTCの活用
ponyo877
0
380
Why Prism?
kddnewton
4
1.7k
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
325
38k
Into the Great Unknown - MozCon
thekraken
29
1.4k
Atom: Resistance is Futile
akmur
261
25k
KATA
mclloyd
27
13k
Art, The Web, and Tiny UX
lynnandtonic
294
20k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
26
1.9k
The Art of Programming - Codeland 2020
erikaheidi
48
13k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
0
130
Build your cross-platform service in a week with App Engine
jlugia
228
18k
Testing 201, or: Great Expectations
jmmastey
36
7k
Build The Right Thing And Hit Your Dates
maggiecrowley
30
2.3k
Large-scale JavaScript Application Architecture
addyosmani
508
110k
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