Skip to content

-stdin prevents program restart on file change #22

@CTNOriginals

Description

@CTNOriginals

When you run wgo with the -stdin flag, the program does not restart right away anymore after a file change.
To get it to work again I first have to press return (enter) to get it unstuck.

I suspect that this is caused by wgo waiting for the next stdin to be entered and that this is done in a blocking manner, but this does kinda defeat the whole purpose of it all.

When i also turn on -verbose logging, it does seem to still detect the file changes right before its supposed to reload and then gets stuck.

$ wgo run -stdin -verbose . --test
[wgo] WATCH /home/ctn/code/bitburner/gofilesync
[wgo] WATCH arguments
[wgo] WATCH build
[wgo] WATCH communication
[wgo] WATCH communication/constructor
[wgo] WATCH communication/definitions
[wgo] WATCH config
[wgo] WATCH constants
[wgo] WATCH debug
[wgo] WATCH test
[wgo] WATCH utils
[wgo] WATCH watcher
[wgo] EXECUTING /usr/bin/go build -o /tmp/wgo_20260202114150_4454 .
[wgo] EXECUTING /tmp/wgo_20260202114150_4454 --test


---- FileSync START 11:41:50 ----
User Input: hello world
Received: hello world
User Input: [wgo] (skip) CREATE test/test.go~
[wgo] CREATE test/test.go
[wgo] WRITE test/test.go

[wgo] EXECUTING /usr/bin/go build -o /tmp/wgo_20260202114150_4454 .
[wgo] EXECUTING /tmp/wgo_20260202114150_4454 --test
 # Gets stuck here
 # I press enter here, which triggers a restart
---- FileSync START 11:42:34 ----
User Input: 

For clarity, this is the code that is ran to produce that log:

fmt.Printf("User Input: ")

scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
	cmd := strings.TrimSpace(scanner.Text())

	fmt.Printf("Received: %s\n", cmd)
	fmt.Printf("User Input: ")
}

Hope this is enough info, and i hope it can be resolved, its driving me nuts.
Regardless though, great tool, been using it for all my projects so im also grateful for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions