version1.go 743 B

123456789101112131415161718192021222324
  1. // Copyright 2011 Google Inc. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package uuid
  5. import (
  6. guuid "github.com/google/uuid"
  7. )
  8. // NewUUID returns a Version 1 UUID based on the current NodeID and clock
  9. // sequence, and the current time. If the NodeID has not been set by SetNodeID
  10. // or SetNodeInterface then it will be set automatically. If the NodeID cannot
  11. // be set NewUUID returns nil. If clock sequence has not been set by
  12. // SetClockSequence then it will be set automatically. If GetTime fails to
  13. // return the current NewUUID returns nil.
  14. func NewUUID() UUID {
  15. gu, err := guuid.NewUUID()
  16. if err == nil {
  17. return UUID(gu[:])
  18. }
  19. return nil
  20. }