Open jwir3 opened 1 year ago
I'm not sure if I understand the question or requirement sorry @jwir3, I should think if you're writing your own function, you can absolutely enforce any specific type on it?
func MakeComputation(value float64, temp units.Celcius) {
...
}
You could even write a generic function in later Go versions...
func MakeComputation[T units.Temperature](value float64, unit T) {
...
}
Can you perhaps further expand/explain your requirement?
For example, if I wanted to be more constrained about the specific type of unit I wanted:
In this particular example,
unit.Temperature
would refer to any ofunit.Celsius
,unit.Fahrenheit
, orunit.Kelvin
. Is there a way to make this slightly more specific like this?