What did you do?
Moused over Meters or any of the other consts.
package si
type Distance int64
const (
Nanometers = 1
Micrometers = 1000 * Nanometers
Millimeters = 1000 * Micrometers
Meters = 1000 * Millimeters
)
// String pretty formats the units to a reasonable human readable representation i.e. "100m", "500nm",
func (v Velocity) String() string {
return formatWithBase(v, baseNano, 'm')
}
What did you expect to see?
What I want is what is currently done today with the time.Duration type:

I understand this implies a HUGE change to gopls, since it would mean somehow running arbitrary code. This carries some worrysome implications:
- Security risk
- How to implement this without exploding gopls binary size
- Recursive risk
I'd understand if this cannot be done today, however I want to start the discussion since this would be a large quality of life improvement for me since I regularly work with SI unit consts to define program behaviour.
I'd also like to refer you all the TinyGo interp package which safely evaluates Go code on initialization: https://github.com/tinygo-org/tinygo/tree/release/interp.
What did you see instead?
Got very long numbers which are not immediately interpretable, much less when defining other more complex consts with the Distance type.

What did you do?
Moused over
Metersor any of the other consts.What did you expect to see?
What I want is what is currently done today with the time.Duration type:

I understand this implies a HUGE change to gopls, since it would mean somehow running arbitrary code. This carries some worrysome implications:
I'd understand if this cannot be done today, however I want to start the discussion since this would be a large quality of life improvement for me since I regularly work with SI unit consts to define program behaviour.
I'd also like to refer you all the TinyGo
interppackage which safely evaluates Go code on initialization: https://github.com/tinygo-org/tinygo/tree/release/interp.What did you see instead?
Got very long numbers which are not immediately interpretable, much less when defining other more complex consts with the Distance type.
