• 请不要在回答技术问题时复制粘贴 AI 生成的内容
eyp82
V2EX  ›  程序员

go 语言里怎么快速找到一个定义(函数, 变量或者其他任意东西)在一个 package 的哪个文件里?

  •  
  •   eyp82 · Jun 23, 2017 · 3613 views
    This topic created in 3429 days ago, the information mentioned may be changed or developed.

    突然发现这个略微蛋疼的问题, 可能很简单就搞定但我不知道: 一个 package 往往有多个文件, 然后我想找到某个函数在哪个文件里, 有什么快速的办法, 难道只能用 grep?

    9 replies  •  2017-06-24 12:05:39 +08:00
    orderc
    orderc
    Jun 23, 2017 via iPhone❤️1
    1
    IDE 点击函数名不是就可以跳转到定义处吗
    cxbig
    cxbig
    Jun 23, 2017
    2
    从来不搜,Gogland 帮我找好了,包括自动 import
    per
    per
    Jun 23, 2017
    3
    yosef
    per
    per
    Jun 23, 2017
    4
    写错了。是 godef
    jarlyyn
    jarlyyn
    Jun 23, 2017 via Android
    6
    Vscode f12
    eyp82
    eyp82
    OP
    Jun 24, 2017
    7
    @orderc 是, 在 IDE 里看到是可以跳转, 不过如果是在别的网页里看到呢, 难道要拷贝粘贴到 IDE 里再跳转. 其他的语言基本上根据 import 的路径可以知道在哪个文件里, go 好像不行?
    感觉一定有很简单的办法, 我大脑有点短路.
    eyp82
    eyp82
    OP
    Jun 24, 2017
    8
    @per 哈哈, 好像就是我要的功能, 谢谢.
    Reficul
    Reficul
    Jun 24, 2017 via Android
    9
    @eyp82 GitHub 可以装 sourcegraph 插件
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2982 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 05:14 · PVG 13:14 · LAX 21:14 · JFK 00:14
    ♥ Do have faith in what you're doing.