// 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 uuid

import (
	
)

// 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) {
	var  UUID
	, ,  := GetTime()
	if  != nil {
		return , 
	}

	 := uint32( & 0xffffffff)
	 := uint16(( >> 32) & 0xffff)
	 := uint16(( >> 48) & 0x0fff)
	 |= 0x1000 // Version 1

	binary.BigEndian.PutUint32([0:], )
	binary.BigEndian.PutUint16([4:], )
	binary.BigEndian.PutUint16([6:], )
	binary.BigEndian.PutUint16([8:], )

	nodeMu.Lock()
	if nodeID == zeroID {
		setNodeInterface("")
	}
	copy([10:], nodeID[:])
	nodeMu.Unlock()

	return , nil
}