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

goc build main.go报错 #376

Open
guo2312668 opened this issue May 11, 2024 · 5 comments
Open

goc build main.go报错 #376

guo2312668 opened this issue May 11, 2024 · 5 comments

Comments

@guo2312668
Copy link

我在用goc收集代码覆盖率,我做的是一个通用的覆盖率收集服务。现在碰到一个问题,有个项目在根目录下有两个go文件都有main(),导致goc build .的时候报错:
./main.go:17: main redeclared in this block
./async.go:19[/goc-build/async.go:20:6]: other declaration of main

但是我制定goc build main.go ,又提示
Fail to build: packages only support "."

业务系统代码我没办法调整和改动,这种情况我该怎么解决呢?

@CarlJi
Copy link
Collaborator

CarlJi commented May 13, 2024

这种放置代码的方式,是有啥背景吗? 感觉挺奇怪的

@HeartIsBeat
Copy link

回复楼上,我们公司就有这种的在cmd/目录下多个main函数,然后是一个仓库,可以分多个服务运行。不同服务,跑不同的main函数。所以楼主这个应该也涉及这种,服务部署都没问题,就是需要哪个main,就把那个main移出来,然后goc build 就ok了

@Jerry1127
Copy link

@CarlJi 我们也是一样的问题,goc build -o不允许指定具体的main包进行编译吗,只能cd到main包所在的目录下,然后goc自己去搜索main包,然后编译吗,如果这个目录下有多个main包,就会出现楼主上面的那个报错

@lizaiganshenmo
Copy link

hi,这种问题,你们是如何解决适配的?

@lizaiganshenmo
Copy link

@CarlJi 我们也是一样的问题,goc build -o不允许指定具体的main包进行编译吗,只能cd到main包所在的目录下,然后goc自己去搜索main包,然后编译吗,如果这个目录下有多个main包,就会出现楼主上面的那个报错

请问你们是如何解决的呢最后

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

5 participants