@kjk1/

gobook exec reuse cmd

Go

No description

fork
loading
Files
  • main.go

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.21226191491936164","path":"main.go","file":{"path":"main.go","content":{"asEncoding":{"base64":"Ly8gbm8gcGxheWdyb3VuZCwgYWxsb3cgZXJyb3IKcGFja2FnZSBtYWluCgppbXBvcnQgKAoJImxvZyIKCSJvcy9leGVjIgopCgpmdW5jIG1haW4oKSB7CgkvLyA6c2hvdyBzdGFydAoJY21kIDo9IGV4ZWMuQ29tbWFuZCgiZ28iLCAidmVyc2lvbiIpCglfLCBlcnIgOj0gY21kLkNvbWJpbmVkT3V0cHV0KCkKCWlmIGVyciAhPSBuaWwgewoJCWxvZy5GYXRhbGYoImZpcnN0IGNtZC5Db21iaW50ZWRPdXRwdXQoKSBmYWlsZWQgd2l0aCAnJXMnXG4iLCBlcnIpCgl9CgoJXywgZXJyID0gY21kLkNvbWJpbmVkT3V0cHV0KCkKCWlmIGVyciAhPSBuaWwgewoJCWxvZy5GYXRhbGYoInNlY29uZCBjbWQuQ29tYmludGVkT3V0cHV0KCkgZmFpbGVkIHdpdGggJyVzJ1xuIiwgZXJyKQoJfQoJLy8gOnNob3cgZW5kCn0="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// no playground, allow error
package main

import (
	"log"
	"os/exec"
)

func main() {
	// :show start
	cmd := exec.Command("go", "version")
	_, err := cmd.CombinedOutput()
	if err != nil {
		log.Fatalf("first cmd.CombintedOutput() failed with '%s'\n", err)
	}

	_, err = cmd.CombinedOutput()
	if err != nil {
		log.Fatalf("second cmd.CombintedOutput() failed with '%s'\n", err)
	}
	// :show end
}