MCPcopy Create free account
hub / github.com/cel-expr/cel-go / ConvertToNative

Method ConvertToNative

ext/network.go:514–522  ·  view source on GitHub ↗

ConvertToNative converts the IP value to a native Go type.

(typeDesc reflect.Type)

Source from the content-addressed store, hash-verified

512
513// ConvertToNative converts the IP value to a native Go type.
514func (i IP) ConvertToNative(typeDesc reflect.Type) (any, error) {
515 if typeDesc == reflect.TypeFor[netip.Addr]() {
516 return i.Addr, nil
517 }
518 if typeDesc.Kind() == reflect.String {
519 return i.Addr.String(), nil
520 }
521 return nil, fmt.Errorf("unsupported type conversion to '%v'", typeDesc)
522}
523
524// ConvertToType converts the IP value to a CEL type.
525func (i IP) ConvertToType(typeValue ref.Type) ref.Val {

Callers 1

Calls 2

KindMethod · 0.65
StringMethod · 0.65

Tested by 1