mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 18:47:47 +00:00
87c2ccb0b9
This commit adds a test for both WebAssembly and Cortex-M targets (which use a different way of goroutine lowering) to show how they lower goroutines. It makes it easier to show how the output changes in future commits.
25 lines
353 B
Go
25 lines
353 B
Go
package main
|
|
|
|
func regularFunctionGoroutine() {
|
|
go regularFunction(5)
|
|
}
|
|
|
|
func inlineFunctionGoroutine() {
|
|
go func(x int) {
|
|
}(5)
|
|
}
|
|
|
|
func closureFunctionGoroutine() {
|
|
n := 3
|
|
go func(x int) {
|
|
n = 7
|
|
}(5)
|
|
print(n) // note: this is racy (but good enough for this test)
|
|
}
|
|
|
|
func funcGoroutine(fn func(x int)) {
|
|
go fn(5)
|
|
}
|
|
|
|
func regularFunction(x int)
|