I am new to Golang and would like to model physical devices for measuring quantities such as light intensity, mass, electric current and so forth. So as a starting point I will define a device struct as follows:
const (
// Light can be measured in the form of luminosity
Light = 1<< iota
Mass
ElectricalCurrent
)
type PhysicalDevice struct{
Owner string
ID string
Description string
}
I am a confused now on how to express the device's capabilities (what it can measure) and the units of measurement. For example I would like to express that a physical device can measure electrical currents in amperes. However, I also want to express that a PhysicalDevice can measure more than one quantity. For example it could measure electrical current and temperature.
The PhysicalDevice's capabilities are not known in advance and can contain an arbitrary combination of capabilities.
I was thinking of using something equivalent to a C++ bitset for expressing the physical quantities a device can measure (would this be the right approach in the first place?).
I did not find the Go bitset type and not sure how to express that. I also need to map the measured physical quantity to a corresponding unit.