()
| 45 | ) |
| 46 | |
| 47 | func main() { |
| 48 | if len(os.Args) == 2 { |
| 49 | switch n := os.Args[1]; n { |
| 50 | case "-h", "-help", "--help", "help": |
| 51 | usage() |
| 52 | os.Exit(0) |
| 53 | |
| 54 | case "dump_commands": |
| 55 | // Undocumented command to do a raw dump of the supported commands. This |
| 56 | // is used by unit tests in ../../stack. |
| 57 | items := make([]string, 0, len(types)) |
| 58 | for n := range types { |
| 59 | items = append(items, n) |
| 60 | } |
| 61 | sort.Strings(items) |
| 62 | for _, n := range items { |
| 63 | fmt.Printf("%s\n", n) |
| 64 | } |
| 65 | os.Exit(0) |
| 66 | |
| 67 | default: |
| 68 | if f, ok := types[n]; ok { |
| 69 | fmt.Printf("GOTRACEBACK=%s\n", os.Getenv("GOTRACEBACK")) |
| 70 | if n == "simple" { |
| 71 | // Since the map lookup creates another call stack entry, add a |
| 72 | // one-off "simple" panic style to test the very minimal case. |
| 73 | // types["simple"].f is never called. |
| 74 | panic("simple") |
| 75 | } |
| 76 | f.f() |
| 77 | os.Exit(3) |
| 78 | } |
| 79 | fmt.Fprintf(stdErr, "unknown panic style %q\n", n) |
| 80 | os.Exit(1) |
| 81 | } |
| 82 | } |
| 83 | usage() |
| 84 | os.Exit(1) |
| 85 | } |
| 86 | |
| 87 | // Mocked in test. |
| 88 | var stdErr io.Writer = os.Stderr |
nothing calls this directly
no test coverage detected
searching dependent graphs…