do Python projects where, when initializing the same I save a variable
I highlighted the word variable. I can’t imagine why you tried to use a Go constant if in Python you used a variable, if you want to do the same then write a compatible code, do not enter another semantics.
A constant must be a value that will never change. A time is the perfect definition of something that changes, it is impossible to take the same data in two executions.
It seems to believe that constant is a variable that does not change its value and this is not correct. To better understand: Constant is really useful? (follow the links).
What I need to do in order to have the same behavior as the first code in Golang?
Keep data as a variable. Only swap const
for var
or assign with :=
.
If you want an immutable variable, Go, today, doesn’t have it, just like Python doesn’t have not even constant.
I don’t think only this will make the behavior of the Python code happen in Go, after Python is using a performance analysis library and in Go is using a library that works with normal hours. I know it’s intuitive to think that you just take the time you started and finish the operation, subtract from each other and you know how long it took, but these time libraries don’t usually have enough resolution and accuracy to deliver reliable results for performance analytics.
As far as I know if you do this with go test
, then why reinvent the wheel?
Simple, direct and exactly what I needed to know about the "why" not working. Thank you very much.
– LeandroLuk