Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ambiguous import #21

Open
niclausse opened this issue Sep 5, 2021 · 3 comments
Open

ambiguous import #21

niclausse opened this issue Sep 5, 2021 · 3 comments

Comments

@niclausse
Copy link

../../../../pkg/mod/github.com/bilibili/[email protected]/builder/rule_builder.go:6:2: ambiguous import: found package github.com/antlr/antlr4/runtime/Go/antlr in multiple modules:

@CodeShaoNian
Copy link

怎么解决的呢

@BiscuitAtLinux
Copy link

BiscuitAtLinux commented Dec 23, 2022

遇到此问题+1,简单研究了一下,原因其实比较简单

  1. gengine 依赖的antlr4版本是一个比较老的版本 github.com/antlr/antlr4 v0.0.0-20210105192202-5c2b686f95e1,这个版本的在 github.com/antlr/antlr4/runtime/Go/antlr 目录下缺少go.mod文件,所以go mod会自动依赖到最上层
  2. 其他一些库(这里叫xxx)依赖了antlr4比较新的版本,子目录下有了go.mod文件,直接依赖到了 github.com/antlr/antlr4/runtime/Go/antlr v1.4.10
  3. 如果同时依赖了gengine和xxx,那么go就傻了,因为antlr下的好多包在这两个依赖目录下都能找到,出现了ambiguous import

解决方法是更新gengine依赖的antlr4版本,并直接依赖到 github.com/antlr/antlr4/runtime/Go/antlr 目录,稍后我提个Pull Request

@BiscuitAtLinux
Copy link

在上述 #57 被合入之前,可以先在 go.mod 里加以下的 replace 语句

replace (
	github.com/bilibili/gengine => github.com/BiscuitAtLinux/gengine v0.0.0-20221223083655-5abe637b1d7b
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants