我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

您如何在Go AST中表示零?

Looking at the Go AST documentation, I don't see any node type to represent a nil in the code. BasicLit doesn't cover it in the list of token types it accepts, and in fact when I look at the source to go/token I don't see a nil token at all!

If I want to create an AST of the form if x != nil, how do I do the nil?

As per the Go specification, nil is a predeclared identifier. Therefore, it is represented by *ast.Ident in an AST:

node := ast.NewIdent("nil")

近期文章

  • 使用Go创建注册表项/字符串
  • 正则表达式“ golang文本匹配之前”
  • 调用需要sockaddr的C函数
  • 如何从github构建Golang博客?
  • 指向struct的nil指针不深等于nil吗?
  • 求一段shellcode解密的方法。
  • 想问一下这个ubuntu装完以后电脑是真的什么资料都没了吗?
  • idea关于tomcat缓存无法清理问题
  • 一些项目中为什么要在一个module中加入module,而不是package,这样做的意义是什么?
  • PyQt5计时器QTimer的停止和重启
  • 51单片机sbit位定义问题
  • android自定义view怎么求圆弧角度?谢谢
  • 请问为什么运行不了呢?
  • ffmpeg解码部分视频失败
  • 怎么在这行代码里面添加背景图片
  • java.sql.SQLException: ORA-28040: 没有匹配的验证协议
  • 可能有一个New函数在Golang中分配文件描述符
  • Heroku找不到Go应用程序
  • 解码二级响应主体以构造
  • 如何使用Go解析方法或函数中的语句

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华