Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bom-d-van/ocisly
package ocisly contains a goroutine Wait function that could be used in testing environment.
https://github.com/bom-d-van/ocisly
Last synced: about 1 month ago
JSON representation
package ocisly contains a goroutine Wait function that could be used in testing environment.
- Host: GitHub
- URL: https://github.com/bom-d-van/ocisly
- Owner: bom-d-van
- License: mit
- Created: 2016-05-13T07:04:36.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-05-24T02:53:28.000Z (over 8 years ago)
- Last Synced: 2024-06-20T00:37:17.543Z (5 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ocisly
package ocisly contains a goroutine Wait function that could be used in testing environment.
Name inspired by SpaceX drone ship [Of Course I Still Love you](https://en.wikipedia.org/wiki/Autonomous_spaceport_drone_ship).
[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](http://godoc.org/github.com/bom-d-van/ocisly)
A simple example
```go
func f() {}func main() {
go f()
ocisly.Wait("github.com/bom-d-van/pkg.f")
}
```Explanations:
```
Wait waits until you named gorouine finish. Using DefaultTimeout (initialized 10 seconds)If the Wait exits before your goroutine started, you could specify a large
IntervalBegin to avoid this problem.How to figure out your function name. Basically it's {{ImportPath}}.{{FuncName}}.
Case 1: function named "Func" from package (same or other) named "github.com/alice/pkg"
ocisly.Wait("github.com/alice/pkg.Func")
Case 2: method named "method" in type "*typ" from package (same or other) named "github.com/alice/pkg"
ocisly.Wait("github.com/alice/pkg.(*typ).method")
Case 3: first anonymous function called "foo" in function/method named "Func" in package (same or other)
named "github.com/alice/pkg".
ocisly.Wait("github.com/alice/pkg.Func.func1")
Running examples could be found in file ocisly_test.go.Disclaimer: cases mentioned above isn't comprehensive, so if your function is
complicated to figure out by human brain, you could call
ocisly.PrintGoroutines() to help you figure out what name is your gorouinte using.Suggestion: to improve Wait accuracy, you could turn your inline/anonymous function to a named function.
```