The Go Programming Language
› http://golang.org/
› Go Playground
Go Projects
› Revel Web Framework
northluo

Goland 引用问题求教

  •  
  •   northluo · Dec 12, 2024 · 2639 views
    This topic created in 691 days ago, the information mentioned may be changed or developed.

    现在有 3 个结构体

    type A struct {
        *B
        ccc.C
    }
    
    type B struct {
        opts *Option
    }
    
    package ccc
    type C struct {
        opts *Option
    }
    
    type Option struct {
        emlog.Logger   // 日志
    }
    
    // 测试函数
    func (a *A) testMethod() {
        a.opts.Logger // 此时 Goland 中 opts 的引用会报错, 提示 Ambiguous reference 'opts' ,但是可以编译 可以运行,因为只能引用 B 里面的 opts ,C 跨包了,是私有的 opts ,但是 Goland 会索引到就很离谱(同事用的 vscode 就没问题)
        a.B.opts.Logger // Goland 不会报错 
    }
    

    各位大佬知道如何配置 goland 解决这个问题吗?

    9 replies  •  2024-12-24 11:39:48 +08:00
    danbai
    danbai
    PRO
    Dec 12, 2024
    1
    清空索引可以吗
    northluo
    northluo
    OP
    Dec 12, 2024
    2
    @danbai 试过两次 还是不行,讲道理小写的 opts 不是同一个包下并不会索引到~~
    pkoukk
    pkoukk
    Dec 12, 2024
    3
    我不用 goland 就是因为 go 明明提供了 gopls ,它非不用...非要自己搓一个...
    MoYi123
    MoYi123
    Dec 12, 2024
    4
    northluo
    northluo
    OP
    Dec 12, 2024
    5
    @MoYi123 我去 还真是~~2 年前的 bug 了,这还不修~
    x1aoYao
    x1aoYao
    Dec 12, 2024
    6
    @pkoukk 是的。JB 一家明显没法像每个语言各自维护的 LSP 做的完善
    imherer
    imherer
    Dec 16, 2024❤️1
    7
    说实话以前还没遇到过类似的问题,但是最近经常遇到各种爆红,结构体点不出来,实际上运行又没问题
    vegeta2ex
    vegeta2ex
    Dec 24, 2024
    8
    @imherer 经常碰到这种,重启才能解决
    imherer
    imherer
    Dec 24, 2024
    9
    @luffy2u 我是重启都解决不了,只要它爆红了,就一直红到底
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5008 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 08:56 · PVG 16:56 · LAX 00:56 · JFK 03:56
    ♥ Do have faith in what you're doing.