V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
eyp82
V2EX  ›  程序员

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

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

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

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