
安装go install github.com/go-delve/delve/cmd/dlvlatestgo-delve的非交互使用方式以非交互方式执行goroutines命令为例dlv-goroutines.sh#!/bin/sh if [ $1 ]; then echo usage: $0 prog_name exit 1 fi prog_name$1 if [ ! -f ./.goroutines.dlv ]; then cat ./.goroutines.dlv EOF goroutines exit EOF fi PID$(ps aux | grep $prog_name | grep -v grep | head -1 | awk {print $2}) yes n | dlv --allow-non-terminal-interactivetrue attach $PID --init .goroutines.dlv其中yes n用于回答exit命令显示的Would you like to kill the process? [Y/n]dlv命令窗口的翻页键d键--end--