I think I understand the overlay part of your question: That sounds a lot like context.Context.Value
. You could build that with something like this:
type Map interface {
Get(key interface{}) (value interface{})
Set(key, value interface{})
}
type goMap map[interface{}]interface{}
func (m goMap) Get(key interface{}) interface{} {
return m[key]
}
func (m goMap) Set(key, value interface{}) {
m[key] = value
}
type fallbackMap struct {
Map
Fallback Map
}
func (m fallbackMap) Get(key interface{}) interface{} {
v := m.Map.Get(key)
if v != nil {
return v
}
return v.Fallback.Get(key)
}
func MakeFallbackMap(fallback Map) Map {
return fallbackMap{make(goMap), fallback}
}
But I don’t know Java so I don’t exactly understand what a “dynamic proxy” is or what the code you’re showing does, but it sounds like you want to intercept calls to something? Can you write some pseudo-code that demonstrates what it’d look like to use the API in Go?