通常の処理
# mian.go var psCmd = &cobra.Command{ Use: "ps", Short: "show process", Run: func(cmd *cobra.Command, args []string) { flag.Parse() args = flag.Args() fmt.Println(args[1]) processes, err := ps.Processes() if err != nil { os.Exit(1) } for _, process := range processes { fmt.Printf("%T type : ", process) fmt.Printf("%v\n", process) } }, }
# interface type Process interface{ Pid() int PPid() int Executable() string }
結果
*ps.DarwinProcess type : &{93021 93009 main} *ps.DarwinProcess type : &{93009 80086 go} *ps.DarwinProcess type : &{92970 1 com.apple.iCloud} *ps.DarwinProcess type : &{92675 1 quicklookd}
やりたいこと
&{92675 1 quicklookd}の部分をstringとして取得したい
ためしたこと
fmt.Printf("%v",process.Pid)
--> 0x13bfbd アドレスが出てきた
fmt.Printf("%v",&process.Pid)
--> エラー
fmt.Printf("%v",*process.Pid)
--> エラー
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/16 06:33