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

Goland 引用问题求教

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