Ejemplo n.º 1
0
func TestPs(t *testing.T) {
	var reader = sh.NewReader(ps, Status{})

	var status []Status
	status = make([]Status, 0)

	for {
		var s Status
		err := sh.Unmarshal(reader, &s)

		if err == io.EOF {
			break
		}
		if err != nil {
			panic(err)
		}
		t.Logf("%#v", s)
		status = append(status, s)
	}
	// t.Logf("%#v", status)
}
Ejemplo n.º 2
0
func Ps() []PsOutput {
	cmd := sh.Command{"docker ps -a"}

	lines, _ := cmd.Lines()
	var reader = sh.NewReader(lines, PsOutput{})

	var status []PsOutput
	status = make([]PsOutput, 0)

	for {
		var s PsOutput
		err := sh.Unmarshal(reader, &s)

		if err == io.EOF {
			break
		}
		if err != nil {
			panic(err)
		}
		status = append(status, s)
	}
	return status
}