Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Build error #83

Open
gongzelong0718 opened this issue Jan 3, 2018 · 7 comments
Open

Build error #83

gongzelong0718 opened this issue Jan 3, 2018 · 7 comments

Comments

@gongzelong0718
Copy link

gongzelong0718 commented Jan 3, 2018

Sorry, I am a newbie for golang. Could you help me with the build error?

zelongg@zelongg:~/Code/youjumpijump$ go version
go version go1.6 linux/amd64
zelongg@zelongg:~/Code/youjumpijump$ CGO_ENABLED=0 GOARCH=arm GOOS=linux go build -o youjumpijump-android android/main.go
android/main.go:14:2: cannot find package "github.com/faceair/youjumpijump" in any of:
	/usr/local/lib/go/src/github.com/faceair/youjumpijump (from $GOROOT)
	($GOPATH not set)
zelongg@zelongg:~/Code/youjumpijump$ vim android/main.go 
zelongg@zelongg:~/Code/youjumpijump$ 
@faceair
Copy link
Owner

faceair commented Jan 3, 2018

move the repository to $GOPATH/src/github.com/faceair folder or go get github.com/faceair/youjumpijump && cd $GOPATH/src/github.com/faceair/youjumpijump && CGO_ENABLED=0 GOARCH=arm GOOS=linux go build -o youjumpijump-android android/main.go

@gongzelong0718
Copy link
Author

Thanks for your reply, mind my asking what is $GOPATH?

Do I need to set the path in environment like ~/.bashrc?

zelongg@zelongg:~/Code/youjumpijump$ go get github.com/faceair/youjumpijump && cd $GOPATH/src/github.com/faceair/youjumpijump && CGO_ENABLED=0 GOARCH=arm GOOS=linux go build -o youjumpijump-android android/main.go
package github.com/faceair/youjumpijump: cannot download, $GOPATH not set. For more details see: go help gopath
vim ~/.bashrc 
#Go
export GOROOT=/usr/local/lib/go
export GOBIN=/usr/local/lib/go/bin
export PATH=$PATH:$GOBIN

@faceair
Copy link
Owner

faceair commented Jan 4, 2018

https://github.com/golang/go/wiki/GOPATH
mkdir~/Code/Go && echo "export GOPATH=~/Code/Go" >> ~/.bashrc

@gongzelong0718
Copy link
Author

mkdir ~/go && echo "export GOPATH=~/go" >> ~/.bashrc
zelongg@zelongg:~/go/src/github.com/faceair/youjumpijump$ CGO_ENABLED=0 GOARCH=arm GOOS=linux go build -o youjumpijump-android android/main.go
# github.com/faceair/youjumpijump
./jump.go:22: undefined: os.Executable

zelongg@zelongg:~/go/src/github.com/faceair/youjumpijump$ go version
go version go1.6 linux/amd64

According to this one, asticode/go-astilectron#9

I had to update the go version from 1.6 to 1.8.

It seems very troublesome to update the go version. But I will have a try.

@gongzelong0718
Copy link
Author

gongzelong0718 commented Jan 4, 2018

https://golang.org/doc/install?download=go1.8.5.linux-amd64.tar.gz

把原来的/usr/local/lib下的go文件夹改名为go1.6
zelongg@zelongg:~/go/src/github.com/faceair/youjumpijump$ sudo mv /usr/local/lib/go/ /usr/local/lib/go1.6

改名后go version,找不到go的命令,说明成功。

zelongg@zelongg:~/go/src/github.com/faceair/youjumpijump$ sudo tar -zxvf ~/Downloads/go1.8.5.linux-amd64.tar.gz -C /usr/local/lib/

zelongg@zelongg:~/go/src/github.com/faceair/youjumpijump$ go versiongo version go1.8.5 linux/amd64

zelongg@zelongg:~/go/src/github.com/faceair/youjumpijump$ CGO_ENABLED=0 GOARCH=arm GOOS=linux go build -o youjumpijump-android android/main.go

zelongg@zelongg:~/go/src/github.com/faceair/youjumpijump$ ls -la
total 5044
drwxrwxr-x 7 zelongg zelongg 4096 1月 4 15:37 .
drwxrwxr-x 3 zelongg zelongg 4096 1月 4 14:46 ..
drwxrwxr-x 2 zelongg zelongg 4096 1月 4 14:47 android
drwxrwxr-x 8 zelongg zelongg 4096 1月 4 15:37 .git
drwxrwxr-x 2 zelongg zelongg 4096 1月 4 14:47 .github
-rw-rw-r-- 1 zelongg zelongg 34 1月 4 14:47 .gitignore
-rw-rw-r-- 1 zelongg zelongg 221 1月 4 14:47 glide.lock
-rw-rw-r-- 1 zelongg zelongg 83 1月 4 14:47 glide.yaml
drwxrwxr-x 2 zelongg zelongg 4096 1月 4 14:47 ios
-rw-rw-r-- 1 zelongg zelongg 3814 1月 4 14:47 jump.go
-rw-rw-r-- 1 zelongg zelongg 4035 1月 4 14:47 README.md
-rw-rw-r-- 1 zelongg zelongg 2029 1月 4 14:47 request.go
-rw-rw-r-- 1 zelongg zelongg 1368 1月 4 14:47 similar.go
drwxrwxr-x 3 zelongg zelongg 4096 1月 4 14:47 vendor
-rwxrwxr-x 1 zelongg zelongg 5227438 1月 4 15:37 youjumpijump-android

generate new file : youjumpijump-android

@gongzelong0718
Copy link
Author

Thanks for your help. I build it successfully.
Have a nice day :)

@gongzelong0718
Copy link
Author

gongzelong0718 commented Jan 15, 2018

1
Could you share any documents about the cross build arguments?
http://blog.jyootai.com/blog/2015/05/08/golang-cross-platform-compile.html
Why CGO_ENABLED=0 GOARCH=arm GOOS=linux
Why not CGO_ENABLED=0 GOARCH=arm64 GOOS=linux
Is it because most of android devices are 32 bit arm linux?

2
https://golang.org/doc/code.html#GOPATH
I thought the output should be in ${GOPATH}/bin
How do you know you can generate youjumpijump-android in ~/go/src/github.com/faceair/youjumpijump
Could you share the document?
Because the official guide only talks about the situation that we only have one .go file.

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

No branches or pull requests

2 participants