Example #1
0
func goroutine(client service.Client, args ...string) error {
	switch len(args) {
	case 0:
		return printscope(client)

	case 1:
		gid, err := strconv.Atoi(args[0])
		if err != nil {
			return err
		}

		oldState, err := client.GetState()
		if err != nil {
			return err
		}
		newState, err := client.SwitchGoroutine(gid)
		if err != nil {
			return err
		}

		fmt.Printf("Switched from %d to %d (thread %d)\n", oldState.SelectedGoroutine.ID, gid, newState.CurrentThread.ID)
		return nil

	default:
		return scopePrefix(client, "goroutine", args...)
	}
}