daemon_client.go 315 Bytes
Newer Older
1 2 3 4
package daemon

import (
	"encoding/json"
5
	"io"
6
	"net"
7
	"os"
8 9
)

10
func SendCommand(com *Command, server string) error {
11 12
	con, err := net.Dial("tcp", server)
	if err != nil {
13
		return err
14 15 16
	}

	enc := json.NewEncoder(con)
17
	err = enc.Encode(com)
18
	if err != nil {
19
		return err
20 21
	}

22
	io.Copy(os.Stdout, con)
23

24
	return nil
25
}