You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

46 lines
784 B

package works
import (
"bytes"
"os/exec"
"time"
)
func Uname(param ...string) (string, error) {
//var cmdParam string
unameCmd := exec.Command("uname")
if len(param) != 0 {
//for _, p := range param {
// cmdParam += p
//}
unameCmd = exec.Command("uname", param...)
}
var out bytes.Buffer
unameCmd.Stdout = &out
err := unameCmd.Run()
if err != nil {
return "", err
}
return out.String(), err
}
func Wait(param ...string) (string, error) {
time.Sleep(10 * time.Second)
return "worker sleep 10s", nil
}
func Echo(param ...string) (string, error) {
var out string
for _, v := range param {
out += v + " "
}
return out, nil
}
func Works() map[string]interface{} {
return map[string]interface{}{
"uname": Uname,
"wait": Wait,
"echo": Echo,
}
}

Powered by TurnKey Linux.