19 lines
322 B
Go
19 lines
322 B
Go
|
package test
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"net"
|
||
|
)
|
||
|
|
||
|
type TestIPGetter struct {
|
||
|
PublicIPProp net.IP
|
||
|
PublicIPFunc func(ctx context.Context) (net.IP, error)
|
||
|
}
|
||
|
|
||
|
func (g *TestIPGetter) GetCurrentPublicIP(ctx context.Context) (net.IP, error) {
|
||
|
if g.PublicIPFunc == nil {
|
||
|
return g.PublicIPProp, nil
|
||
|
}
|
||
|
return g.PublicIPFunc(ctx)
|
||
|
}
|