Skip to content

v0.1.0

Compare
Choose a tag to compare
@vladimirvivien vladimirvivien released this 02 May 18:55
6149013

v0.1.0

This is the first non-alpha release of project gexe. The goal of project gexe is to make it dead simple to write code that interacts with the OS (and/or other components) with the type safety of the Go programming language.

What does it do ?

  • Parse and execute OS comands provided as plain and clear text as you would in a shell.
  • Support for variable expansion in command string (i.e. gexe.Run("echo $HOME"))
  • Get process information (i.e. PID, status, exit code, etc)
  • Stream data from stdout while process is executing
  • Get program information (i.e. args, binary name, working dir, etc)
  • Easily read file content into different targets (string, bytes, io.Writer, etc)
  • Easily write file content from different sources (i.e. string, bytes, io.Reader, etc)
  • Integrate with your shell script using go run

Example

Here is a simple example of how gexe can be used build Go binary for instance.

func main() {
	for _, arch := range []string{"amd64"} {
		for _, opsys := range []string{"darwin", "linux"} {
			gexe.SetVar("arch", arch).SetVar("os", opsys)
			gexe.SetVar("binpath", fmt.Sprintf("build/%s/%s/mybinary", arch, opsys))
			result := gexe.Envs("CGO_ENABLED=0 GOOS=$os GOARCH=$arch").Run("go build -o $binpath .")
			if result != "" {
				fmt.Printf("Build for %s/%s failed: %s\n", arch, opsys, result)
				os.Exit(1)
			}
			fmt.Printf("Build %s/%s: %s OK\n", arch, opsys, echo.Eval("$binpath"))
		}
	}
}

Find more information in the README.