使用修改后的Go软件包分支而不是已安装的软件包

huangapple go评论73阅读模式
英文:

Using modified branch of a Go package instead of installed package

问题

我做了一个"go get"来安装github.com/chsc/gogl。显然,这似乎把一些东西放在了C:\Go\src\pkg\github.com\chsc\gogl。当我导入"github.com/chsc/gogl"时,我可以正常使用这个包。

但是假设我想对这个包进行一些编辑。我该如何管理和组织我的项目和代码?我应该把我的gogl副本放在哪里?如何让我的所有项目都使用我自己的gogl副本,而不是安装在C:\Go\src\pkg\github.com\chsc\gogl下的那个副本?

英文:

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

得分: 3

  1. 创建你的 GitHub 账号
  2. Fork 你自己的 gogl 版本
  3. 运行命令 go get github.com/user782220/gogl(假设 user782220 是你的 GitHub 账号)
英文:
  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)

答案2

得分: 2

你可以修改C:\Go\src\pkg\github.com\chsc\gogl中的代码,然后运行"go install github.com/chsc/gogl"。

另外,如果你打算长期进行更改,最好的选择是在github上fork该项目,然后使用你的fork版本(github.com/yourname/gogl)。

英文:

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).

答案3

得分: 0

你可以在你的项目文件夹中从github.com上获得gogl的副本:

  1. 创建C:/my_go_project/local_github.com/chsc/gogl文件夹

  2. C:\Go\src\pkg\github.com\chsc\gogl中的所有内容复制到C:\my_go_project\local_github.com\chsc\gogl

  3. 在你的.go文件中包含你的库,例如

> import "local_github.com/chsc/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.

huangapple
  • 本文由 发表于 2012年7月19日 08:53:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/11552516.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定