Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues with 'go build' on forked repository

Tags:

go

I build a binary file for a GitHub repo (go code), which works fine. no issues. I forked that repo, and modified a single line in the HTML file that has nothing to do with GO code, built the binary file for the new forked repo but the binary it generates refers to the original repo code, can't understand why.

I even cleaned all the code using go clean -i all command and manually removed all the installed code, binary files from $home/go/bin and the repo directory, but it still refers to the original repo code instead of new forked code.


Based on the solution suggested by Tobias, I performed the following steps: enter image description here

After that, I executed go build in that repo directory, but the new binary file still refers to the old code. I even removed the old binary file and generated a new one.

enter image description here

like image 916
MotsManish Avatar asked Dec 24 '22 01:12

MotsManish


1 Answers

That's a common problem in go. The references system in "location based" so it searches for these files in the "correct" path. Idk if go modules fix this issue, but atleast when not using go modules you'll have to work around it.

You can solve it by

Solution 1

  1. Download the original repository you forked by:

go get http://github.com/awesome-org/tool

  1. Add your fork as remote

git remote add awesome-you-fork http://github.com/awesome-you/tool

  1. You'll have to make changes in the folder of the original downloaded repo and Push and Pull to/from your fork.

git pull --rebase awesome-you-fork

git push awesome-you-fork

Solution 2

Work around go get: You create the path the original repo would have, but clone your own fork into it. That way you can push & pull to your fork. That may be the better solution

cd $GOPATH
mkdir -p {src,bin,pkg}
mkdir -p src/github.com/awesome-org/
cd src/github.com/awesome-org/

git clone [email protected]:awesome-you/tool.git # OR: git clone https://github.com/awesome-you/tool.git
cd tool/
go get ./...

These Solutions were found here: http://code.openark.org/blog/development/forking-golang-repositories-on-github-and-managing-the-import-path

like image 84
Tobias Theel Avatar answered Jan 01 '23 08:01

Tobias Theel