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)
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\n")
fmt.Scanf("h")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With