-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New provision to get fields from specs. #174
Comments
I see that in the On the other hand, adding meta information into interfaces seems wrong. We may have different use cases, and modifying the interface to support it is not always practical. The goal of the
So, an alternative way I see is to remove all |
For the issue, you can follow the same approach as we use in specs.Builder here: Line 319 in 1e9be38
func exportEnc(enc encoding.Encoder) (string, error) {
// set encoding
encType := reflect.TypeOf(enc).Elem().Name()
if e, found := EncodingsIntToExt[encType]; found {
return e, nil
} else {
return "", fmt.Errorf("unknown encoding type: %s", encType)
}
} |
Hi @alovak, I see the method you are describing is already in specs.Builder as you are mentioning. I guess I'm referring to the exposure of those internal methods at the field level, similar to field.Spec().Description but it would be like field.Spec().Encoding or field.Spec().Prefix |
For each package like encName := encoding.Name(encoding.ASCII) // return "" if not found
prefixName := prefix.Name(prefix.ASCII.Fixed) // return "" if not found
// ... we can implement it based on what we have here: https://github.com/moov-io/iso8583/blob/master/specs/builder.go#L162 |
In the describe.go we can get the description from the Specs with the instruction "desc := field.Spec().Description".
There is not provision to get other fields, per example Encoding. I have tried enc := field.Spec().Enc and so far I can just print "&{}"
The goal is to produce an output like this:
Can we add new method to get other fields defined in the specs: encoding, prefix?
The text was updated successfully, but these errors were encountered: