Compile Time Code
Weaving with Go
https://github.com/deferpanic/goweave
Slide 2
Slide 2 text
I like your software but…
Slide 3
Slide 3 text
What sucks about Go?
Slide 4
Slide 4 text
Do you know about aspectj?
Slide 5
Slide 5 text
Really?
Slide 6
Slide 6 text
I’m not a code purist
Slide 7
Slide 7 text
“which is our full
time job . write a
program to write a
program”
- rob pike / gopherfest 2015
Slide 8
Slide 8 text
No content
Slide 9
Slide 9 text
Go is Actually a Decent Fit
Slide 10
Slide 10 text
Prior Art
go fmt
go fix
go generate
Slide 11
Slide 11 text
go fix
Slide 12
Slide 12 text
No Wrapping
I don’t want to update code && leave the refs in
it’s non-trivial
I don’t want to hack it in/out each time
I could forget in the future or not find all in the past
Slide 13
Slide 13 text
Aspect
Contains behavior that is prominent in many places but don’t
really have anything to do with your business logic.
Logging is a canonical example.
Slide 14
Slide 14 text
Pointcut
an expression that details where to apply your behavior
CALL
Before, after or wrap around calling a method.
EXECUTE
Before or after inside executing a method.
WITHIN
Every single call within a method.
Slide 15
Slide 15 text
Advice
fmt.Println("Hello, 世界")
Slide 16
Slide 16 text
Logging
Slide 17
Slide 17 text
Monitoring
Slide 18
Slide 18 text
Performance Analysis
Slide 19
Slide 19 text
Debugging & Tracing
Slide 20
Slide 20 text
Undo Functionality
Slide 21
Slide 21 text
No content
Slide 22
Slide 22 text
Behavior Mutation
Slide 23
Slide 23 text
Security
Slide 24
Slide 24 text
Transactions
Slide 25
Slide 25 text
Log every call to Itoa
Slide 26
Slide 26 text
Validation
Slide 27
Slide 27 text
Time Database Query
Latencies
Slide 28
Slide 28 text
Ensure we log every panic
in a goroutine
Slide 29
Slide 29 text
loom
central place for storing .weave files
you don’t have to re-invent the wheel
more eyes - better software