moov-io / iso8583

A golang implementation to marshal and unmarshal iso8583 message.
https://moov.io
Apache License 2.0
352 stars 105 forks source link

Update `Unmarshal` method for the message and the rest of the fields #282

Closed alovak closed 12 months ago

alovak commented 1 year ago

It should be possible to use native types in data structures like this when we extract data from the message into the struct using Unmarshal:

// define a struct for the authorization request
type AuthorizationResponse struct {
    MTI                  string `index:"0"`
    STAN                 string `index:"11"`
    // ...
}

// usage
request := &AuthorizationResponse{}

message := iso8583.NewMessage(Spec)
err := message.Unpack(someBinaryData)
// handle error
err = message.Unmarshal(request)
// handle error

// request.MTI => "0110"
// request.STAN => "000123"

It should include the following:

the reference implementation is here and it includes update of the message.Unmarshal (src) and field.String/Unmarshal (src):

alovak commented 12 months ago

closed by #291