Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
cc822af1
提交
cc822af1
authored
5月 18, 2016
作者:
Jeromy Johnson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2736 from ipfs/feature/go.uuid-to-gx
Migrate go.uuid to gx from Godeps
上级
6f716463
2c6213e2
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
8 行增加
和
624 行删除
+8
-624
Godeps.json
Godeps/Godeps.json
+0
-4
Godeps.json
...space/src/github.com/ipfs/go-datastore/Godeps/Godeps.json
+0
-4
key.go
Godeps/_workspace/src/github.com/ipfs/go-datastore/key.go
+1
-1
.travis.yml
Godeps/_workspace/src/github.com/satori/go.uuid/.travis.yml
+0
-10
LICENSE
Godeps/_workspace/src/github.com/satori/go.uuid/LICENSE
+0
-20
README.md
Godeps/_workspace/src/github.com/satori/go.uuid/README.md
+0
-66
benchmarks_test.go
...orkspace/src/github.com/satori/go.uuid/benchmarks_test.go
+0
-121
uuid.go
Godeps/_workspace/src/github.com/satori/go.uuid/uuid.go
+0
-397
uuid_test.go
Godeps/_workspace/src/github.com/satori/go.uuid/uuid_test.go
+0
-0
package.json
package.json
+6
-0
loggables.go
thirdparty/loggables/loggables.go
+1
-1
没有找到文件。
Godeps/Godeps.json
浏览文件 @
cc822af1
...
...
@@ -157,10 +157,6 @@
"Rev"
:
"5e4ce6bc0ecd3472f6f943666d84876691be2ced"
},
{
"ImportPath"
:
"github.com/satori/go.uuid"
,
"Rev"
:
"7c7f2020c4c9491594b85767967f4619c2fa75f9"
},
{
"ImportPath"
:
"github.com/steakknife/hamming"
,
"Comment"
:
"0.0.10"
,
"Rev"
:
"8bad99011016569c05320e51be39c648679c5b73"
...
...
Godeps/_workspace/src/github.com/ipfs/go-datastore/Godeps/Godeps.json
浏览文件 @
cc822af1
...
...
@@ -56,10 +56,6 @@
"Rev"
:
"041b88c1fcf6489a5721ede24378ce1253b9159d"
},
{
"ImportPath"
:
"github.com/satori/go.uuid"
,
"Rev"
:
"7c7f2020c4c9491594b85767967f4619c2fa75f9"
},
{
"ImportPath"
:
"github.com/syndtr/goleveldb/leveldb"
,
"Rev"
:
"871eee0a7546bb7d1b2795142e29c4534abc49b3"
},
...
...
Godeps/_workspace/src/github.com/ipfs/go-datastore/key.go
浏览文件 @
cc822af1
...
...
@@ -4,7 +4,7 @@ import (
"path"
"strings"
"g
ithub.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/satori
/go.uuid"
"g
x/ipfs/QmcyaFHbyiZfoX5GTpcqqCPYmbjYNAhRDekXSJPFHdYNSV
/go.uuid"
dsq
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
)
...
...
Godeps/_workspace/src/github.com/satori/go.uuid/.travis.yml
deleted
100644 → 0
浏览文件 @
6f716463
language
:
go
go
:
-
1.0
-
1.1
-
1.2
-
1.3
-
1.4
sudo
:
false
notifications
:
email
:
false
Godeps/_workspace/src/github.com/satori/go.uuid/LICENSE
deleted
100644 → 0
浏览文件 @
6f716463
Copyright (C) 2013-2015 by Maxim Bublis <b@codemonkey.ru>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Godeps/_workspace/src/github.com/satori/go.uuid/README.md
deleted
100644 → 0
浏览文件 @
6f716463
# UUID package for Go language
[

](https://travis-ci.org/satori/go.uuid)
[

](http://godoc.org/github.com/satori/go.uuid)
This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing of UUIDs.
With 100% test coverage and benchmarks out of box.
Supported versions:
*
Version 1, based on timestamp and MAC address (RFC 4122)
*
Version 2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1)
*
Version 3, based on MD5 hashing (RFC 4122)
*
Version 4, based on random numbers (RFC 4122)
*
Version 5, based on SHA-1 hashing (RFC 4122)
## Installation
Use the
`go`
command:
$ go get github.com/satori/go.uuid
## Requirements
UUID package requires any stable version of Go Programming Language.
It is tested against following versions of Go: 1.0-1.4
## Example
```
go
package
main
import
(
"fmt"
"github.com/satori/go.uuid"
)
func
main
()
{
// Creating UUID Version 4
u1
:=
uuid
.
NewV4
()
fmt
.
Printf
(
"UUIDv4: %s
\n
"
,
u1
)
// Parsing UUID from string input
u2
,
err
:=
uuid
.
FromString
(
"6ba7b810-9dad-11d1-80b4-00c04fd430c8"
)
if
err
!=
nil
{
fmt
.
Printf
(
"Something gone wrong: %s"
,
err
)
}
fmt
.
Printf
(
"Successfully parsed: %s"
,
u2
)
}
```
## Documentation
[
Documentation
](
http://godoc.org/github.com/satori/go.uuid
)
is hosted at GoDoc project.
## Links
*
[
RFC 4122
](
http://tools.ietf.org/html/rfc4122
)
*
[
DCE 1.1: Authentication and Security Services
](
http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01
)
## Copyright
Copyright (C) 2013-2015 by Maxim Bublis
<b@codemonkey.ru>
.
UUID package released under MIT License.
See
[
LICENSE
](
https://github.com/satori/go.uuid/blob/master/LICENSE
)
for details.
Godeps/_workspace/src/github.com/satori/go.uuid/benchmarks_test.go
deleted
100644 → 0
浏览文件 @
6f716463
// Copyright (C) 2013-2014 by Maxim Bublis <b@codemonkey.ru>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package
uuid
import
(
"testing"
)
func
BenchmarkFromBytes
(
b
*
testing
.
B
)
{
bytes
:=
[]
byte
{
0x6b
,
0xa7
,
0xb8
,
0x10
,
0x9d
,
0xad
,
0x11
,
0xd1
,
0x80
,
0xb4
,
0x00
,
0xc0
,
0x4f
,
0xd4
,
0x30
,
0xc8
}
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
FromBytes
(
bytes
)
}
}
func
BenchmarkFromString
(
b
*
testing
.
B
)
{
s
:=
"6ba7b810-9dad-11d1-80b4-00c04fd430c8"
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
FromString
(
s
)
}
}
func
BenchmarkFromStringUrn
(
b
*
testing
.
B
)
{
s
:=
"urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
FromString
(
s
)
}
}
func
BenchmarkFromStringWithBrackets
(
b
*
testing
.
B
)
{
s
:=
"{6ba7b810-9dad-11d1-80b4-00c04fd430c8}"
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
FromString
(
s
)
}
}
func
BenchmarkNewV1
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
NewV1
()
}
}
func
BenchmarkNewV2
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
NewV2
(
DomainPerson
)
}
}
func
BenchmarkNewV3
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
NewV3
(
NamespaceDNS
,
"www.example.com"
)
}
}
func
BenchmarkNewV4
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
NewV4
()
}
}
func
BenchmarkNewV5
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
NewV5
(
NamespaceDNS
,
"www.example.com"
)
}
}
func
BenchmarkMarshalBinary
(
b
*
testing
.
B
)
{
u
:=
NewV4
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
u
.
MarshalBinary
()
}
}
func
BenchmarkMarshalText
(
b
*
testing
.
B
)
{
u
:=
NewV4
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
u
.
MarshalText
()
}
}
func
BenchmarkUnmarshalBinary
(
b
*
testing
.
B
)
{
bytes
:=
[]
byte
{
0x6b
,
0xa7
,
0xb8
,
0x10
,
0x9d
,
0xad
,
0x11
,
0xd1
,
0x80
,
0xb4
,
0x00
,
0xc0
,
0x4f
,
0xd4
,
0x30
,
0xc8
}
u
:=
UUID
{}
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
u
.
UnmarshalBinary
(
bytes
)
}
}
func
BenchmarkUnmarshalText
(
b
*
testing
.
B
)
{
bytes
:=
[]
byte
(
"6ba7b810-9dad-11d1-80b4-00c04fd430c8"
)
u
:=
UUID
{}
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
u
.
UnmarshalText
(
bytes
)
}
}
func
BenchmarkMarshalToString
(
b
*
testing
.
B
)
{
u
:=
NewV4
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
u
.
String
()
}
}
Godeps/_workspace/src/github.com/satori/go.uuid/uuid.go
deleted
100644 → 0
浏览文件 @
6f716463
// Copyright (C) 2013-2015 by Maxim Bublis <b@codemonkey.ru>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Package uuid provides implementation of Universally Unique Identifier (UUID).
// Supported versions are 1, 3, 4 and 5 (as specified in RFC 4122) and
// version 2 (as specified in DCE 1.1).
package
uuid
import
(
"bytes"
"crypto/md5"
"crypto/rand"
"crypto/sha1"
"encoding/binary"
"encoding/hex"
"fmt"
"hash"
"net"
"os"
"sync"
"time"
)
// UUID layout variants.
const
(
VariantNCS
=
iota
VariantRFC4122
VariantMicrosoft
VariantFuture
)
// UUID DCE domains.
const
(
DomainPerson
=
iota
DomainGroup
DomainOrg
)
// Difference in 100-nanosecond intervals between
// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970).
const
epochStart
=
122192928000000000
// Used in string method conversion
const
dash
byte
=
'-'
// UUID v1/v2 storage.
var
(
storageMutex
sync
.
Mutex
clockSequence
uint16
lastTime
uint64
hardwareAddr
[
6
]
byte
posixUID
=
uint32
(
os
.
Getuid
())
posixGID
=
uint32
(
os
.
Getgid
())
)
// String parse helpers.
var
(
urnPrefix
=
[]
byte
(
"urn:uuid:"
)
byteGroups
=
[]
int
{
8
,
4
,
4
,
4
,
12
}
)
// Epoch calculation function
var
epochFunc
func
()
uint64
// Initialize storage
func
init
()
{
buf
:=
make
([]
byte
,
2
)
rand
.
Read
(
buf
)
clockSequence
=
binary
.
BigEndian
.
Uint16
(
buf
)
// Initialize hardwareAddr randomly in case
// of real network interfaces absence
rand
.
Read
(
hardwareAddr
[
:
])
// Set multicast bit as recommended in RFC 4122
hardwareAddr
[
0
]
|=
0x01
interfaces
,
err
:=
net
.
Interfaces
()
if
err
==
nil
{
for
_
,
iface
:=
range
interfaces
{
if
len
(
iface
.
HardwareAddr
)
>=
6
{
copy
(
hardwareAddr
[
:
],
iface
.
HardwareAddr
)
break
}
}
}
epochFunc
=
unixTimeFunc
}
// Returns difference in 100-nanosecond intervals between
// UUID epoch (October 15, 1582) and current time.
// This is default epoch calculation function.
func
unixTimeFunc
()
uint64
{
return
epochStart
+
uint64
(
time
.
Now
()
.
UnixNano
()
/
100
)
}
// UUID representation compliant with specification
// described in RFC 4122.
type
UUID
[
16
]
byte
// The nil UUID is special form of UUID that is specified to have all
// 128 bits set to zero.
var
Nil
=
UUID
{}
// Predefined namespace UUIDs.
var
(
NamespaceDNS
,
_
=
FromString
(
"6ba7b810-9dad-11d1-80b4-00c04fd430c8"
)
NamespaceURL
,
_
=
FromString
(
"6ba7b811-9dad-11d1-80b4-00c04fd430c8"
)
NamespaceOID
,
_
=
FromString
(
"6ba7b812-9dad-11d1-80b4-00c04fd430c8"
)
NamespaceX500
,
_
=
FromString
(
"6ba7b814-9dad-11d1-80b4-00c04fd430c8"
)
)
// And returns result of binary AND of two UUIDs.
func
And
(
u1
UUID
,
u2
UUID
)
UUID
{
u
:=
UUID
{}
for
i
:=
0
;
i
<
16
;
i
++
{
u
[
i
]
=
u1
[
i
]
&
u2
[
i
]
}
return
u
}
// Or returns result of binary OR of two UUIDs.
func
Or
(
u1
UUID
,
u2
UUID
)
UUID
{
u
:=
UUID
{}
for
i
:=
0
;
i
<
16
;
i
++
{
u
[
i
]
=
u1
[
i
]
|
u2
[
i
]
}
return
u
}
// Equal returns true if u1 and u2 equals, otherwise returns false.
func
Equal
(
u1
UUID
,
u2
UUID
)
bool
{
return
bytes
.
Equal
(
u1
[
:
],
u2
[
:
])
}
// Version returns algorithm version used to generate UUID.
func
(
u
UUID
)
Version
()
uint
{
return
uint
(
u
[
6
]
>>
4
)
}
// Variant returns UUID layout variant.
func
(
u
UUID
)
Variant
()
uint
{
switch
{
case
(
u
[
8
]
&
0x80
)
==
0x00
:
return
VariantNCS
case
(
u
[
8
]
&
0xc0
)
|
0x80
==
0x80
:
return
VariantRFC4122
case
(
u
[
8
]
&
0xe0
)
|
0xc0
==
0xc0
:
return
VariantMicrosoft
}
return
VariantFuture
}
// Bytes returns bytes slice representation of UUID.
func
(
u
UUID
)
Bytes
()
[]
byte
{
return
u
[
:
]
}
// Returns canonical string representation of UUID:
// 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
(
buf
)
}
// SetVersion sets version bits.
func
(
u
*
UUID
)
SetVersion
(
v
byte
)
{
u
[
6
]
=
(
u
[
6
]
&
0x0f
)
|
(
v
<<
4
)
}
// SetVariant sets variant bits as described in RFC 4122.
func
(
u
*
UUID
)
SetVariant
()
{
u
[
8
]
=
(
u
[
8
]
&
0xbf
)
|
0x80
}
// MarshalText implements the encoding.TextMarshaler interface.
// The encoding is the same as returned by String.
func
(
u
UUID
)
MarshalText
()
(
text
[]
byte
,
err
error
)
{
text
=
[]
byte
(
u
.
String
())
return
}
// UnmarshalText implements the encoding.TextUnmarshaler interface.
// Following formats are supported:
// "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
func
(
u
*
UUID
)
UnmarshalText
(
text
[]
byte
)
(
err
error
)
{
if
len
(
text
)
<
32
{
err
=
fmt
.
Errorf
(
"uuid: invalid UUID string: %s"
,
text
)
return
}
if
bytes
.
Equal
(
text
[
:
9
],
urnPrefix
)
{
text
=
text
[
9
:
]
}
else
if
text
[
0
]
==
'{'
{
text
=
text
[
1
:
]
}
b
:=
u
[
:
]
for
_
,
byteGroup
:=
range
byteGroups
{
if
text
[
0
]
==
'-'
{
text
=
text
[
1
:
]
}
_
,
err
=
hex
.
Decode
(
b
[
:
byteGroup
/
2
],
text
[
:
byteGroup
])
if
err
!=
nil
{
return
}
text
=
text
[
byteGroup
:
]
b
=
b
[
byteGroup
/
2
:
]
}
return
}
// MarshalBinary implements the encoding.BinaryMarshaler interface.
func
(
u
UUID
)
MarshalBinary
()
(
data
[]
byte
,
err
error
)
{
data
=
u
.
Bytes
()
return
}
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
// It will return error if the slice isn't 16 bytes long.
func
(
u
*
UUID
)
UnmarshalBinary
(
data
[]
byte
)
(
err
error
)
{
if
len
(
data
)
!=
16
{
err
=
fmt
.
Errorf
(
"uuid: UUID must be exactly 16 bytes long, got %d bytes"
,
len
(
data
))
return
}
copy
(
u
[
:
],
data
)
return
}
// Scan implements the sql.Scanner interface.
// A 16-byte slice is handled by UnmarshalBinary, while
// a longer byte slice or a string is handled by UnmarshalText.
func
(
u
*
UUID
)
Scan
(
src
interface
{})
error
{
switch
src
:=
src
.
(
type
)
{
case
[]
byte
:
if
len
(
src
)
==
16
{
return
u
.
UnmarshalBinary
(
src
)
}
return
u
.
UnmarshalText
(
src
)
case
string
:
return
u
.
UnmarshalText
([]
byte
(
src
))
}
return
fmt
.
Errorf
(
"uuid: cannot convert %T to UUID"
,
src
)
}
// FromBytes returns UUID converted from raw byte slice input.
// It will return error if the slice isn't 16 bytes long.
func
FromBytes
(
input
[]
byte
)
(
u
UUID
,
err
error
)
{
err
=
u
.
UnmarshalBinary
(
input
)
return
}
// FromString returns UUID parsed from string input.
// Input is expected in a form accepted by UnmarshalText.
func
FromString
(
input
string
)
(
u
UUID
,
err
error
)
{
err
=
u
.
UnmarshalText
([]
byte
(
input
))
return
}
// Returns UUID v1/v2 storage state.
// Returns epoch timestamp and clock sequence.
func
getStorage
()
(
uint64
,
uint16
)
{
storageMutex
.
Lock
()
defer
storageMutex
.
Unlock
()
timeNow
:=
epochFunc
()
// Clock changed backwards since last UUID generation.
// Should increase clock sequence.
if
timeNow
<=
lastTime
{
clockSequence
++
}
lastTime
=
timeNow
return
timeNow
,
clockSequence
}
// NewV1 returns UUID based on current timestamp and MAC address.
func
NewV1
()
UUID
{
u
:=
UUID
{}
timeNow
,
clockSeq
:=
getStorage
()
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
.
SetVariant
()
return
u
}
// NewV2 returns DCE Security UUID based on POSIX UID/GID.
func
NewV2
(
domain
byte
)
UUID
{
u
:=
UUID
{}
switch
domain
{
case
DomainPerson
:
binary
.
BigEndian
.
PutUint32
(
u
[
0
:
],
posixUID
)
case
DomainGroup
:
binary
.
BigEndian
.
PutUint32
(
u
[
0
:
],
posixGID
)
}
timeNow
,
clockSeq
:=
getStorage
()
binary
.
BigEndian
.
PutUint16
(
u
[
4
:
],
uint16
(
timeNow
>>
32
))
binary
.
BigEndian
.
PutUint16
(
u
[
6
:
],
uint16
(
timeNow
>>
48
))
binary
.
BigEndian
.
PutUint16
(
u
[
8
:
],
clockSeq
)
u
[
9
]
=
domain
copy
(
u
[
10
:
],
hardwareAddr
[
:
])
u
.
SetVersion
(
2
)
u
.
SetVariant
()
return
u
}
// NewV3 returns UUID based on MD5 hash of namespace UUID and name.
func
NewV3
(
ns
UUID
,
name
string
)
UUID
{
u
:=
newFromHash
(
md5
.
New
(),
ns
,
name
)
u
.
SetVersion
(
3
)
u
.
SetVariant
()
return
u
}
// NewV4 returns random generated UUID.
func
NewV4
()
UUID
{
u
:=
UUID
{}
rand
.
Read
(
u
[
:
])
u
.
SetVersion
(
4
)
u
.
SetVariant
()
return
u
}
// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name.
func
NewV5
(
ns
UUID
,
name
string
)
UUID
{
u
:=
newFromHash
(
sha1
.
New
(),
ns
,
name
)
u
.
SetVersion
(
5
)
u
.
SetVariant
()
return
u
}
// Returns UUID based on hashing of namespace UUID and name.
func
newFromHash
(
h
hash
.
Hash
,
ns
UUID
,
name
string
)
UUID
{
u
:=
UUID
{}
h
.
Write
(
ns
[
:
])
h
.
Write
([]
byte
(
name
))
copy
(
u
[
:
],
h
.
Sum
(
nil
))
return
u
}
Godeps/_workspace/src/github.com/satori/go.uuid/uuid_test.go
deleted
100644 → 0
浏览文件 @
6f716463
差异被折叠。
点击展开。
package.json
浏览文件 @
cc822af1
...
...
@@ -69,6 +69,12 @@
"hash"
:
"QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku"
,
"name"
:
"go-multihash"
,
"version"
:
"0.0.0"
},
{
"author"
:
"satori"
,
"hash"
:
"QmcyaFHbyiZfoX5GTpcqqCPYmbjYNAhRDekXSJPFHdYNSV"
,
"name"
:
"go.uuid"
,
"version"
:
"1.0.0"
}
],
"gxVersion"
:
"0.4.0"
,
...
...
thirdparty/loggables/loggables.go
浏览文件 @
cc822af1
...
...
@@ -9,7 +9,7 @@ package loggables
import
(
"net"
uuid
"g
ithub.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/satori
/go.uuid"
uuid
"g
x/ipfs/QmcyaFHbyiZfoX5GTpcqqCPYmbjYNAhRDekXSJPFHdYNSV
/go.uuid"
ma
"gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论