FAQ
Hello Everyone,

I've recently run into an edge case where I've created a small utility
program for Windows. It is built with -H=windowsgui to avoid creating a
console window when normally run. However, the program is instrumented
using the log package, and it would be nice if those message were visible
when the program is started from the command line. It is possible for a
program to attach to the console in this case. In essence, when started
through the start menu, such a program will not have a console, but when
started from the command line, the output would be directed to that console.

I can achieve the without modifying the runtime, but would be willing to
submit a patch so that this behaviour was standard.

Regards

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Brad Fitzpatrick at May 21, 2015 at 3:01 am
    That seems like the behavior I'd want too.

    On Wed, May 20, 2015 at 7:58 PM, wrote:

    Hello Everyone,

    I've recently run into an edge case where I've created a small utility
    program for Windows. It is built with -H=windowsgui to avoid creating a
    console window when normally run. However, the program is instrumented
    using the log package, and it would be nice if those message were visible
    when the program is started from the command line. It is possible for a
    program to attach to the console in this case. In essence, when started
    through the start menu, such a program will not have a console, but when
    started from the command line, the output would be directed to that console.

    I can achieve the without modifying the runtime, but would be willing to
    submit a patch so that this behaviour was standard.

    Regards

    --
    You received this message because you are subscribed to the Google Groups
    "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Brainman at May 21, 2015 at 4:32 am

    On Thursday, 21 May 2015 12:58:19 UTC+10, r.w.jo...@gmail.com wrote:

    ... would be willing to submit a patch so that this behaviour was
    standard.

    Thanks for the offer, but I don't like your suggestion. Your proposed
    "standard" behaviour would be confusing for me. "Console" programs get
    console and write to it (even when started from "Start Menu"). "GUI"
    programs don't get console - they display messages via GUI.

    Your use case is unusual (in my opinion). You did achieve what is required
    without modifying any standard libraries. If you think it is useful for
    others, just publish your code somewhere.

    Alex

    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Daniel Theophanes at May 21, 2015 at 3:47 pm
    I'd be interested in the technique you used here. Is it available as a
    package? I'd be interested in trying it out.

    -Daniel

    On Wednesday, May 20, 2015 at 7:58:19 PM UTC-7, r.w.jo...@gmail.com wrote:

    Hello Everyone,

    I've recently run into an edge case where I've created a small utility
    program for Windows. It is built with -H=windowsgui to avoid creating a
    console window when normally run. However, the program is instrumented
    using the log package, and it would be nice if those message were visible
    when the program is started from the command line. It is possible for a
    program to attach to the console in this case. In essence, when started
    through the start menu, such a program will not have a console, but when
    started from the command line, the output would be directed to that console.

    I can achieve the without modifying the runtime, but would be willing to
    submit a patch so that this behaviour was standard.

    Regards
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Govert Versluis at May 21, 2015 at 6:06 pm
    Ditto! This makes a lot of sense and equals how it it done in Linux.
    On Thu, May 21, 2015 at 6:30 AM, Daniel Theophanes wrote:

    I'd be interested in the technique you used here. Is it available as a
    package? I'd be interested in trying it out.

    -Daniel

    On Wednesday, May 20, 2015 at 7:58:19 PM UTC-7, r.w.jo...@gmail.com wrote:

    Hello Everyone,

    I've recently run into an edge case where I've created a small utility
    program for Windows. It is built with -H=windowsgui to avoid creating a
    console window when normally run. However, the program is instrumented
    using the log package, and it would be nice if those message were visible
    when the program is started from the command line. It is possible for a
    program to attach to the console in this case. In essence, when started
    through the start menu, such a program will not have a console, but when
    started from the command line, the output would be directed to that console.

    I can achieve the without modifying the runtime, but would be willing to
    submit a patch so that this behaviour was standard.

    Regards
    --
    You received this message because you are subscribed to the Google Groups
    "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Joe Taber at May 21, 2015 at 11:14 pm
    Consistency with Linux has merit, but I think just packaging this up in an
    easy to use way would be enough.

    If it could be designed to work by just blank-importing a package in your
    project it would be so easy to enable it wouldn't need to be standard. E.g.

         import _ "github.com/x/guiconsole" // if started in gui mode from a
    console on windows, attaches to the console.

    On Thursday, May 21, 2015 at 1:06:11 PM UTC-5, Govert Versluis wrote:

    Ditto! This makes a lot of sense and equals how it it done in Linux.

    On Thu, May 21, 2015 at 6:30 AM, Daniel Theophanes <kard...@gmail.com
    <javascript:>> wrote:
    I'd be interested in the technique you used here. Is it available as a
    package? I'd be interested in trying it out.

    -Daniel


    On Wednesday, May 20, 2015 at 7:58:19 PM UTC-7, r.w.jo...@gmail.com
    wrote:
    Hello Everyone,

    I've recently run into an edge case where I've created a small utility
    program for Windows. It is built with -H=windowsgui to avoid creating a
    console window when normally run. However, the program is instrumented
    using the log package, and it would be nice if those message were visible
    when the program is started from the command line. It is possible for a
    program to attach to the console in this case. In essence, when started
    through the start menu, such a program will not have a console, but when
    started from the command line, the output would be directed to that console.

    I can achieve the without modifying the runtime, but would be willing to
    submit a patch so that this behaviour was standard.

    Regards
    --
    You received this message because you are subscribed to the Google Groups
    "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-dev+...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Minux at May 22, 2015 at 1:47 am

    On Thu, May 21, 2015 at 4:40 PM, Joe Taber wrote:

    Consistency with Linux has merit, but I think just packaging this up in an
    easy to use way would be enough.

    If it could be designed to work by just blank-importing a package in your
    project it would be so easy to enable it wouldn't need to be standard. E.g.

    import _ "github.com/x/guiconsole" // if started in gui mode from a
    console on windows, attaches to the console.
    The package is easy enough to write.

    http://godoc.org/github.com/minux/windows/attachconsole

    Usage:
         import _ "github.com/minux/windows/attachconsole"

    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • R W Johnstone at May 22, 2015 at 1:59 am
    Well, that saves me a little bit of work... Thank-you.

    The package import won't help for packages that write to log in their init,
    but that issue does not apply in my use case.

    Regards,


    On Thursday, 21 May 2015 21:47:33 UTC-4, minux wrote:

    The package is easy enough to write.

    http://godoc.org/github.com/minux/windows/attachconsole

    Usage:
    import _ "github.com/minux/windows/attachconsole"
    --
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedMay 21, '15 at 2:58a
activeMay 22, '15 at 1:59a
posts8
users7
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase