tormoder / fit

A Go package for decoding and encoding Garmin FIT files
MIT License
243 stars 42 forks source link

Add function to set Weight on fit.File #44

Closed davidkroell closed 4 years ago

davidkroell commented 4 years ago

This pull adds functionality to set the WeightFile on the fit.File type. currently only reading is possible.

Best regards, David

tormoder commented 4 years ago

Hi, thank you for your contribution. What would be the use case for this?

It's been a while, but I think a Fit file can only have one type. So setting it to e.g. a WeightFile would require to update at least the FileId message type field also.

It would also be nice to a have generic setter, either through reflection, or a setter for all types as for the getters.

davidkroell commented 4 years ago

Hi, I used this to manually create a Fit File from pure Go and encode it. I haven't found a method or documentation to do this in another way. I debugged the decoding and encoding and i found out that the weight field is private in the fit.File type, so i decided to create a method to set this.

It would also be nice to a have generic setter, either through reflection, or a setter for all types as for the getters.

Yeah, I know but currently I only needed the Weight. I could work on this if you want to.

davidkroell commented 4 years ago

Dear @tormoder, what is the status on this?

colinrgodsey commented 4 years ago

@davidkroell The changes in #49 should make this possible.

tormoder commented 4 years ago

The change by @colinrgodsey is more general, so I will close this PR.

Sorry for my non-responsiveness on this issue.