douche5961 2018-02-06 00:42
浏览 47
已采纳

在自定义GO包顶部提交

I am using sha3 package inside a forked go project. I am using a special feature that does not exist in that package and I had to download a file from gist, insert it into the sha3 package and compile it.
Everything is working fine. However, anyone who wants to run my code, they have to get that file and insert it into standard sha3 package first, install the package and run my project. What is the best way that I can include the gist file and sha3 into my commit, so anyone can just clone and run it? Here is the file path:

workspace-
         |_src__
                |_github.com
                |          |_myproject
                |                     |_codes
                |                     |_.git
                |_golang.org
                           |_x
                             |_crypto
                                    |_sha3
                                         |_custom.go
  • 写回答

2条回答 默认 最新

  • dongle3217 2018-02-06 09:00
    关注

    Since go 1.5, you can put a vendor folder at the root of your project (workspace/src/github.com/myproject/vendor). This folder is an import path. When building, go build will first look for packages inside your vendor folder and if not found, will look inside your $GOPATH.

    You can copy your custom golang.org/x/crypto package inside your vendor folder and add it to your favorite VCS.

    The other solution would be to make a fork of the golang.org/x/crypto repository like github.com/user/mycrypto and use the go get command to get the code like this:

    go get github.com/user/mycrypto
    

    That being said, VonC is right, it's a good practice to use a dependency manager as it will keep track of what version of libraries you have installed, and it allows better portability.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?