Skip to content

Data Types

Tormod Erevik Lea edited this page Oct 1, 2023 · 7 revisions

FIT Base Types and regular types are mapped to Go types as follows:

FIT Base Types

FIT Base Type Go type
enum byte
sint8 int8
uint8 uint8
sint16 int16
uint16 uint16
sint32 int32
uint32 uint32
string string
float32 float32
float64 float64
uint8z uint8
uint16z uint16
uint32z uint32
byte byte

The Go type is set to the same invalid value as specified in SDK if invalid (i.e. 0xFF for byte etc).

FIT Types

Each FIT Type is declared as Go type with the appropriate base type as the underlying type (see the table above). Each type implements the Stringer interface.

Exceptions

  • Go type time.Time is used for FIT types date_time and local_date_time

  • A FIT coordinate field (ending in _lat or _long and of type sint32) is stored as type fit.Latitiude or fit.Longitude.

  • An FIT array field is stored as a slice of the appropriate Go type described above.

Notes

  • Scaled fields can be accessed using getter methods. They are named GetFoofield() and return the field as a float64 with any scale and offset applied. NaN is returned if the underlying field has an invalid value (i.e. is not set).

  • A Dynamic Field can have a different type depending on the reference fields. Type resolution is done using generated Get-methods for each dynamic field.

Clone this wiki locally