You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/02/02 14:07:09 UTC
[incubator-servicecomb-service-center] branch master updated:
SCB-317 Prepare the release for Service-Center-1.0.0-m1 (#270)
This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 52bc8b7 SCB-317 Prepare the release for Service-Center-1.0.0-m1 (#270)
52bc8b7 is described below
commit 52bc8b7fbac052402a128115b3060b5fce3d6684
Author: Mohammad Asif Siddiqui <mo...@huawei.com>
AuthorDate: Fri Feb 2 19:37:08 2018 +0530
SCB-317 Prepare the release for Service-Center-1.0.0-m1 (#270)
* Use satori/go.uuid for generating uuid
* Update manifest
---
NOTICE | 1 +
pkg/uuid/uuid.go | 155 ++-----------------------------------------------------
vendor/manifest | 10 +++-
3 files changed, 14 insertions(+), 152 deletions(-)
diff --git a/NOTICE b/NOTICE
index 2a463ca..7572044 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 0bd1244..eb47fe0 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 c3b3fa5..bb7690c 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
+}
--
To stop receiving notification emails like this one, please contact
littlecui@apache.org.