I have not benchmarked bymyself, nor did I properly profile those codes, but fetching the systems time is expensive. You are basically measuring this…
Instead you should do a fixed number of iterations and measure the time inbetween.
And instead of trying to measure those times and iterations by yourself you should use tools like go test -bench and Benchee to get properly benchmarked values.
Also I have to say, that you do not finish the calculation of the hash in the go version, to make it roughly equivalent to your elixir version you need to call Sum() on it:
for {
if start + interval < int32(time.Now().Unix()) {
break
}
h := sha256.New()
h.Write([]byte("data" + strconv.Itoa(n))).Sum()
n += 1
}


















