3 ms·
I'm sorry, but I just don't think people use code like you're describing. In your mind, you see this: hello := 2 hello * time.Second // oh no But peop
by svnpenn 5y ago
I'm sorry, but I just don't think people use code like you're describing. In your mind, you see this:
hello := 2
hello * time.Second // oh no
But people actually use code like this:
hello := time.Second
hello *=2
People working with Go code (who know what they're doing), don't declare an int, only to immediately cast it to something else.
- chrismorgan 5y agoYou’re looking at this from the application perspective, where with the specific example of durations constant multiplication is certainly far, far more common. But you’re discounting library concerns, where it would not be out of the ordinary to receive a time.Duration and an int64 from parameters or a struct or similar. This is also pretty typical of the trade-offs Go makes: it focuses on making things nice for the application writer, mostly pretty successfully, but at the regular cost of pain and with serious typing compromises for the library writer.