2016-11-04 07:43:04 +02:00
|
|
|
// Copyright 2016 The Go Authors. All rights reserved.
|
2016-11-04 01:56:19 +02:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Program gops is a tool to list currently running Go processes.
|
2016-11-03 23:01:55 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-06-28 18:18:41 +02:00
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
|
2022-06-28 18:14:59 +02:00
|
|
|
"github.com/google/gops/internal/cmd"
|
2016-11-03 23:01:55 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2022-06-28 18:18:41 +02:00
|
|
|
var root = cmd.NewRoot()
|
|
|
|
root.AddCommand(cmd.ProcessCommand())
|
|
|
|
root.AddCommand(cmd.TreeCommand())
|
|
|
|
root.AddCommand(cmd.AgentCommands()...)
|
|
|
|
|
|
|
|
// Legacy support for `gops <pid>` command.
|
|
|
|
//
|
|
|
|
// When the second argument is provided as int as opposed to a sub-command
|
|
|
|
// (like proc, version, etc), gops command effectively shortcuts that
|
|
|
|
// to `gops process <pid>`.
|
|
|
|
if len(os.Args) > 1 {
|
|
|
|
// See second argument appears to be a pid rather than a subcommand
|
|
|
|
_, err := strconv.Atoi(os.Args[1])
|
|
|
|
if err == nil {
|
|
|
|
cmd.ProcessInfo(os.Args[1:]) // shift off the command name
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := root.Execute(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2019-03-20 23:59:55 +02:00
|
|
|
}
|