https://github.com/cocotyty/dpig
Dynamic Proxy Implementation In Go
https://github.com/cocotyty/dpig
aop dynamic-proxy golang
Last synced: about 2 months ago
JSON representation
Dynamic Proxy Implementation In Go
- Host: GitHub
- URL: https://github.com/cocotyty/dpig
- Owner: cocotyty
- Created: 2021-07-15T04:21:47.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-22T10:47:20.000Z (over 4 years ago)
- Last Synced: 2025-10-01T05:43:07.171Z (5 months ago)
- Topics: aop, dynamic-proxy, golang
- Language: Assembly
- Homepage:
- Size: 10.7 KB
- Stars: 44
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
DPig
---
A real Dynamic-Proxy implementation In Go.
## A Glimpse
```go
// xxx
var x InterfaceX = impl.New()
dpig.Component(&x)
// xx
var postCall = func(in, out []reflect.Value) {
log.Println("post call print:", out[0].Interface())
}
dpig.Change(dpig.MethodSelector{Object:"InterfaceX",Method:"GetX"}, dpig.Extend{Post: []dpig.PostCall{postCall}})
x.GetX()
```
## Functions
### Component
`Component` accept a pointer to interface.
Then all method of this interface instance can be dynamic proxied.
### Change
`Change` change the behavior of the matched method.
functions in `Pre` will be executed before the method call.
functions in `Post` will be executed after the method call.