Closed HemanthEverest closed 3 years ago
Changing this will break existing code.
When the UUID package was first implemented, in 2011, GetTime called os.Time which could return an os.Error and GetTime passed that error to its caller, NewUUID, which in turn passes it back to its caller. When changed to use time.Now() there was no longer a path that would return an error, however, the signature could not be changed without breaking backwards compatibility.
If, someday, someone decides to fully follow the standard then a host wide persistent mechanism would need to be used to assure no two processes would ever return the same time value and it would always be monotonically increasing, even across reboots. In that case I guess an error could be returned again, but the real reason is what I said above.
You can see the checkin at https://github.com/pborman/uuid/commit/e130d97558da97862b63559fa31be05c88ce3cc7#diff-9087329ff82d586a2f2e2393b726e00312bbd94506e54899e2012b93041bd698
I see
NewUUID
internally callGetTime
which returnserror
as a return value but this value will always benil
(https://github.com/google/uuid/blob/master/time.go#L45-L67).So, it doesn't make any sense to return error from
NewUUID
when the value is alwaysnil
.