简体   繁体   中英

Using modified branch of a Go package instead of installed package

I did a "go get" to install github.com/chsc/gogl. Apparently this seems to have put stuff in C:\\Go\\src\\pkg\\github.com\\chsc\\gogl. And when I import "github.com/chsc/gogl" I can use the package just fine.

But suppose I wanted to make some edits to the package. How do I manage and organize my projects and code? Where do I put my copy of gogl and how do I get all my projects to use my copy of gogl instead of the one installed under C:\\Go\\src\\pkg\\github.com\\chsc\\gogl?

  1. create your github account
  2. fork your own version of gogl
  3. go get github.com/user782220/gogl (assume user782220 is your github account)

You could modify the code in C:\\Go\\src\\pkg\\github.com\\chsc\\gogl, and run "go install github.com/chsc/gogl".

Alternatively, if you are going to be making changes for the long term, your better bet is to fork that project on github, and use your fork instead (github.com/yourname/gogl).

You can have a copy of gogl from github.com in your project folder:

  1. make the C:/my_go_project/local_github.com/chsc/gogl folder

  2. copy all the contents from C:\\Go\\src\\pkg\\github.com\\chsc\\gogl to C:\\my_go_project\\local_github.com\\chsc\\gogl

  3. include your library in your .go files like

import "local_github.com/chsc/gogl"

Now you can edit your local copy as you wish.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM