little-cui closed pull request #270: SCB-317 Prepare the release for Service-Center-1.0.0-m1 URL: https://github.com/apache/incubator-servicecomb-service-center/pull/270
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/NOTICE b/NOTICE index 2a463ca7..7572044b 100644 --- a/NOTICE +++ b/NOTICE @@ -12,6 +12,7 @@ The following components are provided under the MIT License (http://www.openso github.com/beorn7/perks/quantile github.com/boltdb/bolt +github.com/satori/go.uuid AngularJS v1.6.6 (http://angularjs.org) Bootstrap v3.3.7 (http://getbootstrap.com) diff --git a/pkg/uuid/uuid.go b/pkg/uuid/uuid.go index 0bd12441..eb47fe07 100644 --- a/pkg/uuid/uuid.go +++ b/pkg/uuid/uuid.go @@ -17,159 +17,12 @@ package uuid import ( - "crypto/rand" - "encoding/binary" - "encoding/hex" - "net" "strings" - "sync" - "time" - "unsafe" + "github.com/satori/go.uuid" ) -// UUID layout variants. -const ( - LAYOUT_NCS = iota - LAYOUT_RFC4122 - LAYOUT_MICROSOFT - LAYOUT_FUTURE -) - -// Difference in 100-nanosecond intervals between -// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970). -const EPOCH_START_IN_NS = 122192928000000000 - -const DASH byte = '-' - -var ( - mux sync.Mutex - once sync.Once - epochFunc = unixTimeFunc - random uint16 - last uint64 - hardwareAddr [6]byte -) - -func initRandom() { - buf := make([]byte, 2) - doSafeRandom(buf) - random = binary.BigEndian.Uint16(buf) -} - -func initHardwareAddr() { - interfaces, err := net.Interfaces() - if err == nil { - for _, iface := range interfaces { - if len(iface.HardwareAddr) >= 6 { - copy(hardwareAddr[:], iface.HardwareAddr) - return - } - } - } - - // Initialize hardwareAddr randomly in case - // of real network interfaces absence - doSafeRandom(hardwareAddr[:]) - - // Set multicast bit as recommended in RFC 4122 - hardwareAddr[0] |= 0x01 -} - -func initialize() { - initRandom() - initHardwareAddr() -} - -func doSafeRandom(dest []byte) { - if _, err := rand.Read(dest); err != nil { - panic(err) - } -} - -func unixTimeFunc() uint64 { - return EPOCH_START_IN_NS + uint64(time.Now().UnixNano()/100) -} - -type UUID [16]byte - -func (u UUID) Bytes() []byte { - return u[:] -} - -// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. -func (u UUID) String() string { - buf := make([]byte, 36) - - hex.Encode(buf[0:8], u[0:4]) - buf[8] = DASH - hex.Encode(buf[9:13], u[4:6]) - buf[13] = DASH - hex.Encode(buf[14:18], u[6:8]) - buf[18] = DASH - hex.Encode(buf[19:23], u[8:10]) - buf[23] = DASH - hex.Encode(buf[24:], u[10:]) - - return *(*string)(unsafe.Pointer(&buf)) -} - -func (u *UUID) SetVersion(v byte) { - u[6] = (u[6] & 0x0f) | (v << 4) -} - -func (u UUID) Version() uint { - return uint(u[6] >> 4) -} - -func (u *UUID) SetLayout() { - u[8] = (u[8] & 0xbf) | 0x80 // LAYOUT_RFC4122 -} - -func (u UUID) Layout() uint { - switch { - case (u[8] & 0x80) == 0x00: - return LAYOUT_NCS - case (u[8]&0xc0)|0x80 == 0x80: - return LAYOUT_RFC4122 - case (u[8]&0xe0)|0xc0 == 0xc0: - return LAYOUT_MICROSOFT - } - return LAYOUT_FUTURE -} - -func doInit() (uint64, uint16, []byte) { - once.Do(initialize) - - mux.Lock() - - now := epochFunc() - if now <= last { - random++ - } - last = now - - mux.Unlock() - return now, random, hardwareAddr[:] -} - -func NewV1() UUID { - u := UUID{} - - timeNow, clockSeq, hardwareAddr := doInit() - - binary.BigEndian.PutUint32(u[0:], uint32(timeNow)) - binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32)) - binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48)) - binary.BigEndian.PutUint16(u[8:], clockSeq) - - copy(u[10:], hardwareAddr) - - u.SetVersion(1) - u.SetLayout() - - return u -} +const DASH="-" func GenerateUuid() string { - return strings.Replace(NewV1().String(), string(DASH), "", -1) -} + return strings.Replace(uuid.NewV1().String(), string(DASH), "", -1) +} \ No newline at end of file diff --git a/vendor/manifest b/vendor/manifest index c3b3fa59..bb7690c7 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -568,6 +568,14 @@ "revision": "d670f9405373e636a5a2765eea47fac0c9bc91a4", "branch": "HEAD", "notests": true + }, + { + "importpath": "github.com/satori/go.uuid", + "repository": "https://github.com/satori/go.uuid", + "vcs": "git", + "revision": "879c5887cd475cd7864858769793b2ceb0d44feb", + "branch": "HEAD", + "notests": true } ] -} \ No newline at end of file +} ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services