Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdin I/O prevent goroutine execution (Mac, linux) #4397

Open
ldemailly opened this issue Aug 8, 2024 · 0 comments
Open

stdin I/O prevent goroutine execution (Mac, linux) #4397

ldemailly opened this issue Aug 8, 2024 · 0 comments

Comments

@ldemailly
Copy link
Contributor

ldemailly commented Aug 8, 2024

package main

import (
	"fmt"
	"time"
)

func main() {
	go func() {
		time.Sleep(1 * time.Second)
		fmt.Println("from goroutine")
	}()
	fmt.Print("prompt>")
	var x string
	fmt.Scanln(&x)
	fmt.Printf("Read %q\n", x)
}

With normal go, "from goroutine" prints while waiting at the prompt

$ tinygo run main.go 
prompt>Read ""

(so stdin isn't there when running through tinygo run but that's not the main issue/bug:

tinygo build -o tinymain main.go 
./tinymain
prompt> 

🦗

expected

$ go run main.go 
prompt>from goroutine
abc
Read "abc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant