Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
85b61269
提交
85b61269
authored
2月 27, 2015
作者:
Henry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
godeps: update go-uuid
上级
cffef5b5
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
138 行增加
和
10 行删除
+138
-10
Godeps.json
Godeps/Godeps.json
+2
-2
LICENSE
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/LICENSE
+1
-1
json.go
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/json.go
+30
-0
json_test.go
...workspace/src/code.google.com/p/go-uuid/uuid/json_test.go
+32
-0
seq_test.go
..._workspace/src/code.google.com/p/go-uuid/uuid/seq_test.go
+66
-0
time.go
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/time.go
+5
-5
version1.go
..._workspace/src/code.google.com/p/go-uuid/uuid/version1.go
+2
-2
没有找到文件。
Godeps/Godeps.json
浏览文件 @
85b61269
...
...
@@ -11,8 +11,8 @@
},
{
"ImportPath"
:
"code.google.com/p/go-uuid/uuid"
,
"Comment"
:
"null-1
2
"
,
"Rev"
:
"
7dda39b2e7d5e265014674c5af696ba4186679e9
"
"Comment"
:
"null-1
5
"
,
"Rev"
:
"
35bc42037350f0078e3c974c6ea690f1926603ab
"
},
{
"ImportPath"
:
"code.google.com/p/go.crypto/blowfish"
,
...
...
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/LICENSE
浏览文件 @
85b61269
Copyright (c) 2009 Google Inc. All rights reserved.
Copyright (c) 2009
,2014
Google Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
...
...
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/json.go
0 → 100644
浏览文件 @
85b61269
// Copyright 2014 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
"errors"
func
(
u
UUID
)
MarshalJSON
()
([]
byte
,
error
)
{
if
len
(
u
)
==
0
{
return
[]
byte
(
`""`
),
nil
}
return
[]
byte
(
`"`
+
u
.
String
()
+
`"`
),
nil
}
func
(
u
*
UUID
)
UnmarshalJSON
(
data
[]
byte
)
error
{
if
len
(
data
)
==
0
||
string
(
data
)
==
`""`
{
return
nil
}
if
len
(
data
)
<
2
||
data
[
0
]
!=
'"'
||
data
[
len
(
data
)
-
1
]
!=
'"'
{
return
errors
.
New
(
"invalid UUID format"
)
}
data
=
data
[
1
:
len
(
data
)
-
1
]
uu
:=
Parse
(
string
(
data
))
if
uu
==
nil
{
return
errors
.
New
(
"invalid UUID format"
)
}
*
u
=
uu
return
nil
}
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/json_test.go
0 → 100644
浏览文件 @
85b61269
// Copyright 2014 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
(
"encoding/json"
"reflect"
"testing"
)
var
testUUID
=
Parse
(
"f47ac10b-58cc-0372-8567-0e02b2c3d479"
)
func
TestJSON
(
t
*
testing
.
T
)
{
type
S
struct
{
ID1
UUID
ID2
UUID
}
s1
:=
S
{
ID1
:
testUUID
}
data
,
err
:=
json
.
Marshal
(
&
s1
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
var
s2
S
if
err
:=
json
.
Unmarshal
(
data
,
&
s2
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
reflect
.
DeepEqual
(
&
s1
,
&
s2
)
{
t
.
Errorf
(
"got %#v, want %#v"
,
s2
,
s1
)
}
}
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/seq_test.go
0 → 100644
浏览文件 @
85b61269
// Copyright 2014 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
(
"flag"
"runtime"
"testing"
"time"
)
// This test is only run when --regressions is passed on the go test line.
var
regressions
=
flag
.
Bool
(
"regressions"
,
false
,
"run uuid regression tests"
)
// TestClockSeqRace tests for a particular race condition of returning two
// identical Version1 UUIDs. The duration of 1 minute was chosen as the race
// condition, before being fixed, nearly always occured in under 30 seconds.
func
TestClockSeqRace
(
t
*
testing
.
T
)
{
if
!*
regressions
{
t
.
Skip
(
"skipping regression tests"
)
}
duration
:=
time
.
Minute
done
:=
make
(
chan
struct
{})
defer
close
(
done
)
ch
:=
make
(
chan
UUID
,
10000
)
ncpu
:=
runtime
.
NumCPU
()
switch
ncpu
{
case
0
,
1
:
// We can't run the test effectively.
t
.
Skip
(
"skipping race test, only one CPU detected"
)
return
default
:
runtime
.
GOMAXPROCS
(
ncpu
)
}
for
i
:=
0
;
i
<
ncpu
;
i
++
{
go
func
()
{
for
{
select
{
case
<-
done
:
return
case
ch
<-
NewUUID
()
:
}
}
}()
}
uuids
:=
make
(
map
[
string
]
bool
)
cnt
:=
0
start
:=
time
.
Now
()
for
u
:=
range
ch
{
s
:=
u
.
String
()
if
uuids
[
s
]
{
t
.
Errorf
(
"duplicate uuid after %d in %v: %s"
,
cnt
,
time
.
Since
(
start
),
s
)
return
}
uuids
[
s
]
=
true
if
time
.
Since
(
start
)
>
duration
{
return
}
cnt
++
}
}
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/time.go
浏览文件 @
85b61269
...
...
@@ -40,15 +40,15 @@ func (t Time) UnixTime() (sec, nsec int64) {
}
// GetTime returns the current Time (100s of nanoseconds since 15 Oct 1582) and
//
adjusts the clock sequence as needed. An error is returned if the current
// time cannot be determined.
func
GetTime
()
(
Time
,
error
)
{
//
clock sequence as well as adjusting the clock sequence as needed. An error
//
is returned if the current
time cannot be determined.
func
GetTime
()
(
Time
,
uint16
,
error
)
{
defer
mu
.
Unlock
()
mu
.
Lock
()
return
getTime
()
}
func
getTime
()
(
Time
,
error
)
{
func
getTime
()
(
Time
,
uint16
,
error
)
{
t
:=
timeNow
()
// If we don't have a clock sequence already, set one.
...
...
@@ -63,7 +63,7 @@ func getTime() (Time, error) {
clock_seq
=
((
clock_seq
+
1
)
&
0x3fff
)
|
0x8000
}
lasttime
=
now
return
Time
(
now
),
nil
return
Time
(
now
),
clock_seq
,
nil
}
// ClockSequence returns the current clock sequence, generating one if not
...
...
Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/version1.go
浏览文件 @
85b61269
...
...
@@ -19,7 +19,7 @@ func NewUUID() UUID {
SetNodeInterface
(
""
)
}
now
,
err
:=
GetTime
()
now
,
seq
,
err
:=
GetTime
()
if
err
!=
nil
{
return
nil
}
...
...
@@ -34,7 +34,7 @@ func NewUUID() UUID {
binary
.
BigEndian
.
PutUint32
(
uuid
[
0
:
],
time_low
)
binary
.
BigEndian
.
PutUint16
(
uuid
[
4
:
],
time_mid
)
binary
.
BigEndian
.
PutUint16
(
uuid
[
6
:
],
time_hi
)
binary
.
BigEndian
.
PutUint16
(
uuid
[
8
:
],
clock_
seq
)
binary
.
BigEndian
.
PutUint16
(
uuid
[
8
:
],
seq
)
copy
(
uuid
[
10
:
],
nodeID
)
return
uuid
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论