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

go.mod not found #39

Closed
shrimalmadhur opened this issue Sep 2, 2021 · 7 comments · Fixed by #40
Closed

go.mod not found #39

shrimalmadhur opened this issue Sep 2, 2021 · 7 comments · Fixed by #40

Comments

@shrimalmadhur
Copy link

shrimalmadhur commented Sep 2, 2021

Hello I am running into this weird issue where it says go.mod not found, even though there's a go.mod in that folder

INFO: go.mod not found. Skipping go modules
INFO: Cross compiling github.com/coinbase/rosetta-cli package...
INFO: Docker run --rm -v /Users/madhurshrimal/go/src/github.com/coinbase/rosetta-cli:/build -v /var/folders/sc/0crln36d57j1zx_dkp18spn40000gn/T/xgo-cache:/deps-cache:ro -e REPO_REMOTE= -e REPO_BRANCH= -e PACK= -e DEPS= -e ARGS= -e OUT=rosetta-cli-0.7.0 -e FLAG_V=false -e FLAG_X=false -e FLAG_RACE=false -e FLAG_TAGS= -e FLAG_LDFLAGS= -e FLAG_BUILDMODE=default -e TARGETS=darwin/. windows/. linux/. -v /Users/madhurshrimal/go/src:/ext-go/1/src:ro -e EXT_GOPATH=/ext-go/1 ghcr.io/crazy-max/xgo:1.16 github.com/coinbase/rosetta-cli
Building locally github.com/coinbase/rosetta-cli...
Compiling for darwin-10.12/amd64...
go: go.mod file not found in current directory or any parent directory; see 'go help modules'
ERROR: Failed to cross compile package: exit status 1.

I am using xgo -go 1.16 --targets="darwin/*,windows/*,linux/*" -out "rosetta-cli-0.7.0" .
Just to add more clarity, It does work when I do xgo -go 1.16 --targets="darwin/*,windows/*,linux/*" -out "rosetta-cli-0.7.0" github.com/coinbase/rosetta-cli but it doesn't work when I do that in current directory

Interestingly I was not getting this when I was using https://github.com/karalabe/xgo

@bonifaido
Copy link

I'm still having this issue, when using this in a local repostory, I'm not sure if this scenario is supported:

Example:

git clone git@github.com:banzaicloud/bank-vaults.git
cd bank-vaults
xgo --targets=darwin/arm64 ./cmd/bank-vaults

Output:

DBG: config: &{Repository:./cmd/bank-vaults Package: Prefix: Remote: Branch: Dependencies: Arguments: Targets:[darwin/arm64]}
DBG: flags: &{Verbose:false Steps:false Race:false Tags: LdFlags: Mode:default}
INFO: go.mod not found. Skipping go modules
INFO: Cross compiling github.com/banzaicloud/bank-vaults/cmd/bank-vaults package...
INFO: Docker run --rm -v /Users/bonifaido/Code/src/github.com/banzaicloud/bank-vaults:/build -v /var/folders/3q/l731kzc93bd307ftq5b4d18c0000gp/T/xgo-cache:/deps-cache:ro -e REPO_REMOTE= -e REPO_BRANCH= -e PACK= -e DEPS= -e ARGS= -e OUT= -e FLAG_V=false -e FLAG_X=false -e FLAG_RACE=false -e FLAG_TAGS= -e FLAG_LDFLAGS= -e FLAG_BUILDMODE=default -e TARGETS=darwin/arm64 -v /Users/bonifaido/Code/src:/ext-go/1/src:ro -e EXT_GOPATH=/ext-go/1 ghcr.io/crazy-max/xgo:latest github.com/banzaicloud/bank-vaults/cmd/bank-vaults
Building locally github.com/banzaicloud/bank-vaults/cmd/bank-vaults...
Compiling for darwin-10.12/arm64...
go: go.mod file not found in current directory or any parent directory; see 'go help modules'

@shrimalmadhur
Copy link
Author

@bonifaido is it because you are providing ./cmd/bank-vaults in there? You don't have go.mod in that folder. You just need to do that in current dir by providing .. That should work I guess.

@bonifaido
Copy link

bonifaido commented Oct 16, 2021

There is a CLI built from this directory (it has a main() method) and I would like to build that, the root (.) doesn't hold any compilable sources on that level. This is a common idiom in Go AFAIK to have the CLIs built from ./cmd/... according to: https://github.com/golang-standards/project-layout

@shrimalmadhur
Copy link
Author

I see. but xgo expects a go.mod from the directory where you are building. Not sure how to work around for your case.

@bonifaido
Copy link

This worked in karalabe/xgo.

@shrimalmadhur
Copy link
Author

I see. in that case, I would defer this to the @crazy-max for this. I have not looked into the differences between these 2 repos. :)

@sungwoncho
Copy link

@bonifaido using -pkg might solve your problem. Here is how I am using it for a similar situation https://github.com/dnote/dnote/blob/master/scripts/cli/build.sh#L80-L89

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

Successfully merging a pull request may close this issue.

3 participants