dongzhi4073 2018-10-14 22:11
浏览 25

是否有Golang库去解析源和返回STDL​​IB的标识列表?

I'm looking for a library that should parse a go source code and returns the list of identifies related to the Go's standard library. For instance, after processing the following code:

package main

import (
    "os"
    "os/signal"
    "syscall"
)

func main() {
    c := make(chan os.Signal, 1)
    signal.Notify(c, syscall.SIGINT, syscall.SIGUSR2)
}

the output should resemble something like: os: Signal: 1 os/signal: Notify: 1 syscall: SIGINT: 1, SIGUSR2: 1

  • 写回答

1条回答 默认 最新

  • douzhan6474 2018-10-15 01:19
    关注

    I’m not sure what you want to do specifically, but generally a list of tokens isn’t particularly useful. Generally you want to look at walking an AST (Abstract Syntax Tree) which gives you most of the same information within a more meaningful context. For this you probably want to look at the go/ast and go/parser standard library packages should give you most of what you want.

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题