dpkt31779 2018-01-22 12:26
浏览 158
已采纳

在goimport匹配多个具有相同名称的软件包时,如何强制VSCode要求手动选择?

I just ran into issues where I am writing small web service with Go Iris framework. Iris has few useful packages for HTTP request error handling.

Namely, I wanted to use "github.com/kataras/iris/middleware/logger" and "github.com/kataras/iris/middleware/recover" however when I start typing app.Use(logger....) VSCode auto imported "github.com/hashicorp/consul/logger" which is also in my path.

Simply copy-pasting right path will solve the issue, but is there a way to force VSCode to make a manual choice where multiple packages names are matched or even fully disable goimports for these cases.

Example below:

package main

import (
    // "github.com/hashicorp/consul/logger" ! incorrect package

    "github.com/kataras/iris"
    "github.com/kataras/iris/middleware/logger"
    "github.com/kataras/iris/middleware/recover"
)

func main() {
    app := iris.New()
    app.Logger().SetLevel("debug")
    // Optionally, add 2 built'n handlers
    // that can recover from any http-related error
    // and log the requests in terminal
    app.Use(recover.New())
    app.Use(logger.New())
}
  • 写回答

1条回答 默认 最新

  • douju6651 2018-01-22 20:25
    关注

    If you start typing in the import () declaration, it will give you suggestions that match. So if you were to type logger it would give you the suggestion of:

    github.com/kataras/iris/middleware/logger
    

    and

    github.com/hashicorp/consul/logger
    

    Just put the "" in the import and start typing the package you want.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码