问题描述
我不太熟悉 display
中的 dlv
命令。官方文档使用说明
display -a [%format] <expression>
display -d <number>
但我不知道如何写 expression
和 formats
现在我有了代码:
package main
func main(){
ch:=make(chan int,10)
ch<-1
}
如果使用 print
命令,我得到了很多细节
> main.main() ./main.go:4 (PC: 0x4688a0)
1: package main
2: func main(){
3: ch:=make(chan int,10)
=> 4: ch<-1
5: }
(dlv) print ch
chan int {
qcount: 0,dataqsiz: 10,buf: *[10]int [0,0],elemsize: 8,closed: 0,elemtype: *runtime._type {size: 8,ptrdata: 0,hash: 4149441018,tflag: tflagUncommon|tflagExtraStar|tflagNamed|tflagRegularMemory (15),align: 8,fieldAlign: 8,kind: 2,equal: runtime.memequal64,gcdata: *7,str: 636,ptrToThis: 17856},sendx: 0,recvx: 0,recvq: waitq<int> {
first: *sudog<int> nil,last: *sudog<int> nil,},sendq: waitq<int> {
first: *sudog<int> nil,lock: runtime.mutex {
lockRankStruct: runtime.lockRankStruct {},key: 0,}
但是如果我使用 display
命令,只能得到很少的信息
(dlv) display -a ch
0: ch = chan int 0/10
(dlv) l
> main.main() ./main.go:4 (PC: 0x4688a0)
1: package main
2: func main(){
3: ch:=make(chan int,10)
=> 4: ch<-1
5: }
我确实尝试过写表达式,但是 dlv
说语法错误
(dlv) display -a print(ch)
1: print(ch) = error function calls not allowed without using 'call'
(dlv) display -a "%T" ch
2: "%T" ch = error 1:6: expected 'EOF',found ch
(dlv) display -a print ch
3: print ch = error 1:7: expected 'EOF',found ch
(dlv) display -a (%V) ch
4: (%V) ch = error 1:2: expected operand,found '%'
(dlv) display -a print ch
5: print ch = error 1:7: expected 'EOF',found ch
(dlv) display -a print
6: print = error could not find symbol value for print
如何使 display
显示更多详细信息?
任何答复将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)