Documentation ¶
Overview ¶
powershell provides a PowerShell session in which you can execute commands serially (one at a time).
It detects the current code page when a session is created. And when running a command, it encodes the command and decodes the output from stdout or stderr with the encoding corresponding to the code page.
Example ¶
shell, err := powershell.New() if err != nil { log.Fatal(err) } defer shell.Exit() stdout, err := shell.Exec("echo こんにちは") if err != nil { log.Fatal(err) } fmt.Println(stdout) stdout, err = shell.Exec("Get-TimeZone | Select-Object StandardName") if err != nil { log.Fatal(err) } fmt.Println(stdout)
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Encodings = map[int]encoding.Encoding{ 932: japanese.ShiftJIS, 949: korean.EUCKR, 65001: unicode.UTF8, }
Encodings contains a mapping from code page to encoding. Only code page 932 and 65001 are supported by default. To use with other code pages, you need to add an entry before calling the New method.
View Source
var ErrUnsupportedCodePage = errors.New("unsupported code page")
ErrUnsupportedCodePage is the error returned from the New method if the detected code page is not in the Encodings map.
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.