* hadiesmail...@gmail.com <hadiesmail...@gmail.com> [161005 09:16]:
> but i test this code it does not work!
> 
> Why??

People would be able to help you better if you said what you tried (by
giving code; you can use play.golang.org if you want), and saying what
happened and what you expected or wanted to happen.  Also, sometimes the
environment you are using is important.  In this case, I am guessing
that you are running Windows and trying this in a cmd.exe window, which
is an important detail.

The cls command is a builtin command in cmd.exe, not an external
cls.exe.  This means that you cannot invoke it directly with
exec.Command("cls").  Using exec.Command("cmd", "/c", "cls") does what I
expect from a Windows cmd.exe shell.  Complete code:

package main

import (
    "fmt"
    "os"
    "os/exec"
)

func main() {
    var cls = exec.Command("cmd", "/c", "cls")
    cls.Stdout = os.Stdout
    var err = cls.Run()
    if err != nil {
        fmt.Fprintf(os.Stderr, "error: %s\n", err)
    }
}

...Marvin

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

Reply via email to