Add testutils/jaillover to assist testing process spawning

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
This commit is contained in:
pancho horrillo
2019-10-09 16:15:52 +02:00
parent 2e2fcc4edd
commit 273058c3ba
+35
View File
@@ -0,0 +1,35 @@
package main
import (
"encoding/json"
"fmt"
"log"
"os"
"strings"
)
type Output struct {
Cmdline []string `json:"cmdline"`
Env map[string]string `json:"env"`
}
func getEnvMap() map[string]string {
env := make(map[string]string)
for _, e := range os.Environ() {
s := strings.SplitN(e, "=", 2)
env[s[0]] = s[1]
}
return env
}
func main() {
o := Output{
Cmdline: os.Args,
Env: getEnvMap(),
}
res, err := json.Marshal(o)
if err != nil {
log.Fatalf("JSON marshal failed %+v", err)
}
fmt.Println(string(res))
}