Closed shunf4 closed 11 months ago
I have the same problem...
any update on this ? I have the same problem :(
The subcommand's stdin and stderr are output by here: https://github.com/cosmtrek/air/blob/v1.43.0/runner/engine.go#L504-L505 The stderr is not copied until stdin has finished copying. Thus, stderr is outputed after the command is finished and stdin is closed. It might be a good idea to call copy functions in parallel.
On macOS, the subcommand's stdout and stderr are overridden to use os.Stdout and os.Stderr by here: https://github.com/cosmtrek/air/blob/v1.43.0/runner/util_darwin.go#L44-L45 This makes stderr outputs immediately. Incidentally, prepared subcommand's pipes are not used, and the copy functions causing this issue do nothing.
Lastly, on Linux, the subcommand is wrapped by pty, stdout and stderr are merged into the same stream. https://github.com/cosmtrek/air/blob/v1.43.0/runner/util_linux.go#L33 Therefore, subcommand's stderr is output immediately but it is outputed to the stdout of the air.
I don't know which implementation is the best.
Please try arelo, a simpler auto reload tool. It will work well on windows.
go install github.com/makiuchi-d/arelo@latest
arelo -p '**/*.go' -i '**/.*' -- go run .
I came across the same problem. The only way I found to avoid Ctrl-C was by making the air server restart by saving the file again.
If your application never exits, because of a running HTTP server for example, you will never see your (error) messages and wonder why your application doesn't work.
This dependency is now broken on Windows. Useless for development unless you never log to stderr.
Reverting to v1.30.0 allows you to develop again: go install github.com/cosmtrek/air@v1.30.0
go install github.com/cosmtrek/air@v1.30.0
downgrade resolve many problem!!
the last version, even prevent my app read reply from other web site!!
This pull request fixes the issue #389
I also have this problem
main.go:
.air.toml:
Current Behaviour
Running
air
,2023/04/13 23:54:26 abc
does not get printed. Only after hittingCtrl-C
does the log line show.Expected Behaviour
Log lines on stderr get printed immediately as
log.Printf(...)
is called, just as when running the application withoutair
.