forked from didi/sharingan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yufeng
committed
May 3, 2020
1 parent
362273c
commit f5e8a96
Showing
2 changed files
with
16 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
package sharingan_test | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/didi/sharingan" | ||
) | ||
|
||
func Example() { | ||
sharingan.SetDelegatedFromGoRoutineID(1) | ||
doneChan := make(chan bool) | ||
|
||
// goroutineID = 0 「without any tag,default」 | ||
// goroutineID = 1 「with recorder or replayer」 | ||
goroutineID := sharingan.GetCurrentGoRoutineID() | ||
go func(delegatedID int64) { | ||
sharingan.SetDelegatedFromGoRoutineID(delegatedID) | ||
defer sharingan.SetDelegatedFromGoRoutineID(0) | ||
|
||
//Output: | ||
//goroutineID = 0 | ||
fmt.Printf("goroutineID = %d\n", goroutineID) | ||
http.Get("http://127.0.0.1:8888") | ||
|
||
doneChan <- true | ||
}(sharingan.GetCurrentGoRoutineID()) | ||
|
||
<-doneChan | ||
} |