英文:
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
- 创建你的 GitHub 账号
- Fork 你自己的 gogl 版本
- 运行命令
go get github.com/user782220/gogl
(假设 user782220 是你的 GitHub 账号)
英文:
- create your github account
- fork your own version of gogl
- 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的副本:
-
创建C:/my_go_project/local_github.com/chsc/gogl文件夹
-
将
C:\Go\src\pkg\github.com\chsc\gogl
中的所有内容复制到C:\my_go_project\local_github.com\chsc\gogl
-
在你的.go文件中包含你的库,例如
> import "local_github.com/chsc/gogl"
现在你可以随意编辑你的本地副本了。
英文:
You can have a copy of gogl from github.com in your project folder:
-
make the C:/my_go_project/local_github.com/chsc/gogl folder
-
copy all the contents
fromC:\Go\src\pkg\github.com\chsc\gogl
toC:\my_go_project\local_github.com\chsc\gogl
-
include your library in your .go files like
> import "local_github.com/chsc/gogl"
Now you can edit your local copy as you wish.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论