From 50c041108dc321cf37f191dfb697cee0ade426d2 Mon Sep 17 00:00:00 2001 From: "Paul Buetow (europa)" Date: Sun, 24 May 2015 23:25:26 +0100 Subject: Learned about Stringer and now I am using it --- process/process.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'process/process.go') diff --git a/process/process.go b/process/process.go index 9004349..c0e25e2 100644 --- a/process/process.go +++ b/process/process.go @@ -13,10 +13,17 @@ type Process struct { Cmdline string } +func (self *Process) String() string { + str := "=========================" + + str = str + fmt.Sprintf("PID: %d\n", self.Pid) + str = str + fmt.Sprintf("cmdline: %s\n", self.Cmdline) + + return str +} + func (self *Process) Print() { - fmt.Printf("=====================\n") - fmt.Printf("PID: %d\n", self.Pid) - fmt.Printf("cmdline: %s\n", self.Cmdline) + fmt.Println(self) } func Gather(res chan<- Process) { -- cgit v1.2.3