Skip to content
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

Update Marshal method for the fields to accept Go native types #279

Closed
alovak opened this issue Sep 8, 2023 · 1 comment
Closed

Update Marshal method for the fields to accept Go native types #279

alovak opened this issue Sep 8, 2023 · 1 comment

Comments

@alovak
Copy link
Contributor

alovak commented Sep 8, 2023

We want to support Go's native types such as string, int, etc. when we set data to the field using Marshal method

So, the idea is to implement the following:

f := field.NewString(someSpec)

err := f.Marshal("hello")
f.Value() // "hello"

err := f.Marshal(5)
f.Value() // "5"

str := "hello"
err := f.Marshal(&str)
f.Value() // "hello"

i := 5
err := f.Marshal(&i)
f.Value() // "5"

We want to be able to use:

  • int, *int, string, *string for field.Numeric, field.String
  • []byte, string for field.Binary, field.Hex (string should be hex and if we fail to decode it, return error)

Reference implementation is in this PR: https://github.com/moov-io/iso8583/pull/273/files

@alovak
Copy link
Contributor Author

alovak commented Oct 6, 2023

closed by #289

@alovak alovak closed this as completed Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant