From 881574ed39aa294930effe4c0fa08f01c8da3863 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sat, 1 Jun 2024 16:14:26 +0800 Subject: [PATCH] README: goroutine --- README.md | 2 +- _demo/goroutine/goroutine.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 _demo/goroutine/goroutine.go diff --git a/README.md b/README.md index 2c9e95f1..9d406da8 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,6 @@ Common Go syntax is already supported. Except for the following, which needs to * defer (Not supported yet) * gc (Not supported yet) * chan (Not supported yet) -* goroutine (Not supported yet) * generics (Not supported yet) Here are some examples related to Go syntax: @@ -183,6 +182,7 @@ Here are some examples related to Go syntax: * [concat](_demo/concat/concat.go): define a variadic function * [genints](_demo/genints/genints.go): various forms of closure usage (including C function, recv.method and anonymous function) * [errors](_demo/errors/errors.go): demo to implement error interface +* [goroutine](_demo/goroutine/goroutine.go): goroutine demo ## Go packages support diff --git a/_demo/goroutine/goroutine.go b/_demo/goroutine/goroutine.go new file mode 100644 index 00000000..7b420dfc --- /dev/null +++ b/_demo/goroutine/goroutine.go @@ -0,0 +1,12 @@ +package main + +func main() { + done := false + go func() { + println("Hello, goroutine") + done = true + }() + for !done { + print(".") + } +}