siddontang / go Goto Github PK
View Code? Open in Web Editor NEWmy golang lib
License: MIT License
my golang lib
License: MIT License
run following command and test case is not passed
go test ./... -test.v -test.cpu=1,2,4
go test ./... -test.v -test.short -test.race
siddontang,在查看你的时间轮代码时候,觉得(TimingWheel)After()函数中index计算不正确,为了验证猜想,我写了如下测试用例:
输出是:expect time cost 100s, while real time cost is 110 s.
显然,当运行次数越多,你的timingwheel的时间误差将越多,我给你修正后的(TimingWheel)After()函数代码如下:
func (w *TimingWheel) After(timeout time.Duration) <-chan struct{} {
if timeout >= w.maxTimeout {
panic("timeout too much, over maxtimeout")
}
index := int(timeout / w.interval)
if 0 < index {
index--
}
w.Lock()
index = (w.pos + index) % len(w.cs)
b := w.cs[index]
w.Unlock()
return b
}
再次运行我的测试用例后,输出如下:
expect time cost 100s, while real time cost is 100 s.
This output is perfect.
你好,我是不是要在run方法中w.onTicker()这行上面开一个协程去处理时间轮当前位置里面要处理的逻辑啊,例如关闭socket连接等操作
cb568a3 does not pass unit tests with Go 1.10. At least:
Testing: "/builddir/build/BUILD/go-cb568a3e5cc06256f91a2da5a87455f717eb33f4/_build/src/github.com/siddontang/go/filelock"
+ GOPATH=/builddir/build/BUILD/go-cb568a3e5cc06256f91a2da5a87455f717eb33f4/_build:/usr/share/gocode
+ go test -buildmode pie -compiler gc -ldflags '-extldflags '\''-Wl,-z,relro '\'''
# github.com/siddontang/go/filelock
./file_lock_test.go:43: Fatal call has possible formatting directive %s
FAIL github.com/siddontang/go/filelock [build failed]
+ GOPATH=/builddir/build/BUILD/go-cb568a3e5cc06256f91a2da5a87455f717eb33f4/_build:/usr/share/gocode
+ go test -buildmode pie -compiler gc -ldflags '-extldflags '\''-Wl,-z,relro '\'''
# github.com/siddontang/go/list2
./list_test.go:60: Errorf format %p has arg p of wrong type int
./list_test.go:73: Errorf format %p has arg n of wrong type int
FAIL github.com/siddontang/go/list2 [build failed]
siddontang,在查看你的时间轮代码时候,觉得(TimingWheel)After()函数中index计算不正确,为了验证猜想,我写了如下测试用例:
输出是:expect time cost 100s, while real time cost is 110 s.
显然,当运行次数越多,你的timingwheel的时间误差将越多,我给你修正后的(TimingWheel)After()函数代码如下:
`func (w *TimingWheel) After(timeout time.Duration) <-chan struct{} {
if timeout >= w.maxTimeout {
panic("timeout too much, over maxtimeout")
}
index := int(timeout / w.interval)
if 0 < index {
index--
}
w.Lock()
index = (w.pos + index) % len(w.cs)
b := w.cs[index]
w.Unlock()
return b
}`
再次运行我的测试用例后,输出如下:
expect time cost 100s, while real time cost is 100 s.
This output is perfect.
go test failed bson_test
`----------------------------------------------------------------------
FAIL: bson_test.go:597: S.TestMarshalErrorItems
bson_test.go:600:
c.Assert(err, ErrorMatches, item.data)
... error string = "Attempted to marshal Raw kind 10 as a document"
... regex string = "Attempted to unmarshal Raw kind 10 as a document"
FAIL: bson_test.go:1429: S.TestObjectIdJSONUnmarshalingError
bson_test.go:1432:
c.Assert(err, ErrorMatches, Invalid ObjectId in JSON: "4d88e15b60f486e428412dc9A"
)
... error string = "invalid ObjectId in JSON: "4d88e15b60f486e428412dc9A""
... regex string = "Invalid ObjectId in JSON: "4d88e15b60f486e428412dc9A""`
test passed.
OS: gnu/linux
golang: go version go1.9.2 linux/amd64
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.