Random number within range and a given granularity in Golang

Keywords´╝Ü go random granularity


I've written the following code to create a random number between 0.0 and 10.0.

const minRand = 0
const maxRand = 10
v := minRand + rand.Float64()*(maxRand-minRand)

However I would like to set the granularity to 0.05, so having ALL the digits as the least significant decimal should not be allowed, only the "0" and the 5 should be allowed, e.g.:

  • the value 7.73 is NOT VALID,
  • the values 7.7 and 7.75 ARE VALID.

How could I create such numbers using Go?