drrog9853 2016-05-06 12:21
浏览 1805

在golang中,如何通过双击启动exe的程序完成后保持控制台窗口打开

in windows when startup by double click the .exe and when the programe is done by os.Exit(...) so,is there anyway to keep the console window open,just like auto run an cmd command. I dontn want some solution with some PAUSE or some others thing to let it wait close.I need completed exit the program,and keep the console window .

BTW,I think some way of open another console window,but fail with this code

c :=exec.Command("start")

    if err := c.Run(); err != nil {
        fmt.Println("Error: ", err)
    }
    os.Exit(0)

</div>
  • 写回答

3条回答 默认 最新

  • doujieluo5875 2019-09-19 21:50
    关注

    You could call fmt.Scanf(). I know it's hack and you wouldn't want to do it in a production application, but it works.

    package main
    
    import "fmt"
    
    func main() {
        fmt.Printf("hello, world
    ")
        fmt.Scanf("h")
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素