I'm new to golang and want to know if there is any way to intercept a function.
For example, if I have:
func (foo Foo) f1(a int) int {...}
func (foo Foo) f2(a, b int) int {...}
func (foo Foo) f3(a, b, c int) int {...}
and I want to implement some logging function, instead of putting pre and post interceptor in each function:
func (foo Foo) f1(a int) int {
preCall()
...
postCall()
}
func (foo Foo) f2(a, b int) int {
preCall()
...
postCall()
}
func (foo Foo) f3(a, b, c int) int {
preCall()
...
postCall()
}
Is there a better pattern to do this in go? Such as AOP in Java.
Thanks