Package gopwsh is a simple host for PowerShell with-in your Go code.
Originally inspired by https://github.com/bhendo/go-powershell
go get -u github.com/brad-jones/gopwsh
package main
import (
"fmt"
"github.com/brad-jones/gopwsh"
)
func main() {
shell := gopwsh.MustNew()
defer shell.Exit()
stdout, _, err := shell.Execute("Get-ComputerInfo")
if err != nil {
panic(err)
}
fmt.Println(stdout)
}
Also see further working examples under: https://github.com/brad-jones/gopwsh/tree/master/examples
PowerShell these days of course is a cross platform shell, able to run on Windows, MacSO & Linux.
This go module should in theory work on all those platforms too.
But (at this stage) has not been tested anywhere apart from Windows. Who uses PowerShell outside of Windows... sorry thats short sighted & naive of me.
Eventually I'll get around to writing a full test suite but until then if you are one of these users & notice a bug, PRs are of course welcome :)