So I'm a Go developer, there has been a number of times now where I have needed to modify the Go standard library packages, such as net/http.
Several occasions now I've ran into a problem when I'm updating the Go version on my system, once I update Go, of course I need to re-modify the libaries, usually I cannot just copy and replace the folder, as there may be critical updates in the new version.
I know the answer is with Git, but exactly how should I go about this? Lets again take the net/http package for example, which steps do I need to take to link the official repo to my fork, and the steps I should take to merge this with the original after I've installed/upgraded Go?
Steps on how to create the repo, link the original repo and merge/download the repo to a new installation would be greatly appriciated.
CodePudding user response:
To begin with I'm not a go developer, but having to modify the language standard library sound like it may not be the best approach.
Having said that, I believe what you want is to fork the golang repository. This will make a copy of it for you. You can then make changes on that fork. Then, if you want to get updates from "upstream" (the official golang repository) you can sync your fork. This is possibly going to create conflicts that you'll have to fix, as when the same line of code is modified in two different places git doesn't know how to handle this, and is up to the developer to decide.
CodePudding user response:
I would suggest reading about the bridge pattern, where you call your own solution and under the hood, call theirs. And for the stuff that needs change of fixing, don't call theirs. Make a test for it, and then, you are probably good to go ;-)