Re: [go-nuts] Re: Windows Binaries and stdout

2022-05-05 Thread Jason D
It should be doable with just go code and the windows package.. CreateFile can do the same work that freopen is doing. The *CreateFile* function enables a process to get a handle to its console's input

Re: [go-nuts] Re: Windows Binaries and stdout

2022-05-04 Thread stephen.t....@gmail.com
The blog is very interesting. However, I can't see how to re-implement this in Go with only the syscall package or the golang.org/x/sys/windows package. It needs the functionality of C++ freopen(), which as far as I can tell is not possible with the WinAPI - From what I can gather, ReOpen()

Re: [go-nuts] Re: Windows Binaries and stdout

2022-05-04 Thread stephen.t....@gmail.com
Yes. Logging to a file is probably the simplest option for this particular use case. On Monday, May 2, 2022 at 2:27:22 PM UTC+1 anderson...@elastic.co wrote: > You could log to a file. If you're willing to take in a -log flag, you > could take a path as well and log to this file. That way you

Re: [go-nuts] Re: Windows Binaries and stdout

2022-05-02 Thread Robert Engels
https://www.tillett.info/2013/05/13/how-to-create-a-windows-program-that-works-as-both-as-a-gui-and-console-application/ > On May 2, 2022, at 8:27 AM, 'Anderson Queiroz' via golang-nuts > wrote: > > You could log to a file. If you're willing to take in a -log flag, you could > take a path as

Re: [go-nuts] Re: Windows Binaries and stdout

2022-05-02 Thread 'Anderson Queiroz' via golang-nuts
You could log to a file. If you're willing to take in a -log flag, you could take a path as well and log to this file. That way you don't need 2 binaries, however you'd need to tail the file, which seems to me better than 2 binaries. Best, Anderson On Friday, April 29, 2022 at 2:47:06 PM

Re: [go-nuts] Re: Windows Binaries and stdout

2022-04-29 Thread stephen.t....@gmail.com
You're right, it is a Windows issue. I can see that now. I bought up the issue originally because I was unsure if there was something in addition to -H=windows or -H=windowsgui that I could make use of. My understanding of Windows is now exhausted. The alternative way is to have two binaries

Re: [go-nuts] Re: Windows Binaries and stdout

2022-04-29 Thread jake...@gmail.com
This is really a Windows issue, and not related to Go. According to this very old post: https://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-application it is technically possible to do that, but the technique has flaws, foibles and limitations. This

Re: [go-nuts] Re: Windows Binaries and stdout

2022-04-29 Thread Stephen Illingworth
Hello Alex. Thanks for your response. On Fri, Apr 29, 2022 at 9:34 AM brainman wrote: > Once windows executable is built, go has no control over how this program > executes. > > When command line program is executed by clicking in explorer window > Windows automatically starts a new console

[go-nuts] Re: Windows Binaries and stdout

2022-04-29 Thread brainman
Hello Stephen, Windows uses special flag in every executable binary to determine if executable is a GUI or command line program. go program uses "-H windows" linker flag to set that flag. See debug/pe.TestBuildingWindowsGUI for details. Once windows executable is built, go has no control over

[go-nuts] Re: Windows Binaries and stdout

2022-04-29 Thread stephen.t....@gmail.com
I've read through my post again. I'll try to simplify my question: Where is stdout for a Windows "GUI binary"? (see -H option) https://pkg.go.dev/cmd/link If I run from the command prompt I would have thought that stdout is the console I'm running from but if the executable is a "GUI binary"