Goravel v1.17 Preview: Add Process facade, simpler to call system commands



This content originally appeared on DEV Community and was authored by Bowen

facades add a new core module: Process, it’s simpler to call system commands in your application. It has been merged to the master branch, thanks to the core developer @kkumargcc for the contribution.

Core Features

  1. Use the Run function to execute one command.
  2. Use the Pipe function to execute multiple commands.
  3. Use the Pool function to execute command concurrently.
  4. Provide multiple functions to judge and operate the execution result.

Usage Guide


// Run
result, err := facades.Process().Run("echo", "Hello, World!")

// Pipe
result, err := facades.Process().Pipe(func(pipe contracts.Pipe) {
  pipe.Command("echo", "Hello, World!")
  pipe.Command("grep", "World")
  pipe.Command("tr", "a-z", "A-Z")
}).Run()

// Pool
poolResults, err := facades.Process().Pool(func(pool contracts.Pool) {
  pool.Command("sleep", "1").As("sleep1")
  pool.Command("echo", "hello").As("echo1")
  pool.Command("echo", "world").As("echo2")
}).Run()

For details in PR: https://github.com/goravel/framework/pull/1232


This content originally appeared on DEV Community and was authored by Bowen