-
-
Notifications
You must be signed in to change notification settings - Fork 463
-
For example:
import ( someapi "xxxx" ) type SomeStruct struct { Type someapi.SomeType }
The expression I want to execute is to validate the value of an enumeration.
someStruct.Type == someapi.SomeType_TypeOne
errors encountered:
failed: unknown name someapi
This error is easy to understand, but I don't know how to import the "someapi" package into expr context.
I tried to convert the type to int32, but it didn't work
int32(someStruct.Type.Number())==1
failed: unknown func int32
The only solution I've found so far is to convert to string
someStruct.Type.String()=="Day"
This looks more expensive, so I want to seek the best practice.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
You can use Patch to override this part.
Beta Was this translation helpful? Give feedback.
All reactions
-
In order to use someapi it should be a struct.
Unfortunately Go’s reflect doesn’t support reflection on packages.
Beta Was this translation helpful? Give feedback.