// Copyright 2016 Google Inc. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package uuidimport ()// NewUUID returns a Version 1 UUID based on the current NodeID and clock// sequence, and the current time. If the NodeID has not been set by SetNodeID// or SetNodeInterface then it will be set automatically. If the NodeID cannot// be set NewUUID returns nil. If clock sequence has not been set by// SetClockSequence then it will be set automatically. If GetTime fails to// return the current NewUUID returns nil and an error.//// In most cases, New should be used.func () (UUID, error) {varUUID , , := GetTime()if != nil {return , } := uint32( & 0xffffffff) := uint16(( >> 32) & 0xffff) := uint16(( >> 48) & 0x0fff) |= 0x1000// Version 1binary.BigEndian.PutUint32([0:], )binary.BigEndian.PutUint16([4:], )binary.BigEndian.PutUint16([6:], )binary.BigEndian.PutUint16([8:], )nodeMu.Lock()ifnodeID == zeroID {setNodeInterface("") }copy([10:], nodeID[:])nodeMu.Unlock()return , nil}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.