Skip to content

Instantly share code, notes, and snippets.

View lee8oi's full-sized avatar

Lee Forest lee8oi

  • independant/hobby
  • Michigan, USA
View GitHub Profile
@lee8oi
lee8oi / startProcess.go
Last active September 10, 2024 18:10
Using os.StartProcess() in Go for platform-independent system command execution.
package main
import (
"os"
"os/exec"
)
func Start(args ...string) (p *os.Process, err error) {
if args[0], err = exec.LookPath(args[0]); err == nil {
var procAttr os.ProcAttr
@lee8oi
lee8oi / goshell.go
Last active December 18, 2023 18:17
Running system commands interactively in Go using os/exec
package main
import (
"os"
"os/exec"
)
func Command(args ...string) {
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr