{"id":3977,"date":"2019-11-11T20:42:27","date_gmt":"2019-11-11T12:42:27","guid":{"rendered":"https:\/\/damogame.cn\/wordpress\/?p=3977"},"modified":"2019-11-11T20:42:27","modified_gmt":"2019-11-11T12:42:27","slug":"golang-%e5%ae%98%e6%96%b9%e4%be%9d%e8%b5%96%e7%ae%a1%e7%90%86%e5%b7%a5%e5%85%b7-dep-%e4%bd%bf%e7%94%a8%e5%92%8c%e6%8c%81%e7%bb%ad%e9%9b%86%e6%88%90","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/3977","title":{"rendered":"golang \u5b98\u65b9\u4f9d\u8d56\u7ba1\u7406\u5de5\u5177 dep \u4f7f\u7528\u548c\u6301\u7eed\u96c6\u6210"},"content":{"rendered":"<div class=\"rEsl9f\">\n<div class=\"_2mYfmT\">\n<div>\n<div class=\"s-dsoj\"><a href=\"https:\/\/www.jianshu.com\/p\/3a4c69179a09\">\u539f\u6587\u5730\u5740<\/a><\/div>\n<div><\/div>\n<\/div>\n<\/div>\n<\/div>\n<article class=\"_2rhmJa\">[TOC]<\/p>\n<h1>\u4ecb\u7ecd<\/h1>\n<p>go dep \u4f9d\u8d56\u7ba1\u7406\u5de5\u5177\u662f\u4e3a\u5e94\u7528\u7ba1\u7406\u4ee3\u7801\u7684\uff0cgo get\u662f\u4e3aGOPATH\u7ba1\u7406\u4ee3\u7801\u7684<\/p>\n<p>\u5b98\u65b9\u4ee3\u7801\u5730\u5740\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgithub.com%2Fgolang%2Fdep\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/golang\/dep<\/a><br \/>\n\u5b98\u65b9\u8bf4\u660e\u4e3a\u5565\u8981\u7edf\u4e00\u4f9d\u8d56\u7ba1\u7406\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgithub.com%2Fgolang%2Fdep%2Fblob%2Fmaster%2Fdocs%2FFAQ.md%23does-dep-replace-go-get\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/golang\/dep\/blob\/master\/docs\/FAQ.md#does-dep-replace-go-get<\/a><br \/>\n\u5b98\u65b9\u6587\u6863\u5730\u5740\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgolang.github.io%2Fdep%2Fdocs%2Fintroduction.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/golang.github.io\/dep\/docs\/introduction.html<\/a><\/p>\n<p><code>dep \u9700\u8981\u5728Go 1.7\u53ca\u66f4\u9ad8\u7684\u7248\u672c\u4e2d\u4f7f\u7528<\/code><\/p>\n<h1>\u5b89\u88c5<\/h1>\n<p>\u672c\u6587\u4f7f\u7528 golang \u7248\u672c\u662f go1.9.3 \u9700\u8981\u81ea\u5df1\u5b89\u88c5 dep<\/p>\n<pre class=\"line-numbers  language-sh\"><code class=\"sh  language-sh\">go get -v -u github.com\/golang\/dep\/cmd\/dep\r\n<\/code><button class=\"VJbwyy\" type=\"button\" aria-label=\"\u590d\u5236\u4ee3\u7801\"><i class=\"anticon anticon-copy\" aria-label=\"icon: copy\"><\/i><\/button><\/pre>\n<h1>\u57fa\u7840\u5e2e\u52a9\u53c2\u6570<\/h1>\n<pre class=\"line-numbers  language-sh\"><code class=\"sh  language-sh\"> $ dep\r\nDep is a tool for managing dependencies for Go projects\r\nUsage: \"dep [command]\"\r\nCommands:\r\n  init Set up a new Go project, or migrate an existing one\r\n  status Report the status of the project's dependencies\r\n  ensure Ensure a dependency is safely vendored in the project\r\n  prune Pruning is now performed automatically by dep ensure.\r\n  version Show the dep version information\r\nExamples:\r\n  dep init set up a new project\r\n  dep ensure install the project's dependencies\r\n  dep ensure -update update the locked versions of all dependencies\r\n  dep ensure -add github.com\/pkg\/errors add a dependency to the project\r\nUse \"dep help [command]\" for more information about a command.\r\n<\/code><button class=\"VJbwyy\" type=\"button\" aria-label=\"\u590d\u5236\u4ee3\u7801\"><i class=\"anticon anticon-copy\" aria-label=\"icon: copy\"><\/i><\/button><\/pre>\n<blockquote><p>ensure \u786e\u4fdd\uff0c\u786e\u4fdd\u6240\u6709\u672c\u5730\u72b6\u6001-\u4ee3\u7801\u6811\u3001\u4f9d\u8d56\u5217\u8868\u3001\u9501\u3001\u8fdc\u7aefoss\u5f7c\u6b64\u540c\u6b65<\/p><\/blockquote>\n<h1>\u4f7f\u7528<\/h1>\n<h2>\u521d\u59cb\u5316<\/h2>\n<pre class=\"line-numbers  language-sh\"><code class=\"sh  language-sh\">dep init\r\n# \u66f4\u5efa\u8bae\u4f7f\u7528\uff0c\u56e0\u4e3a\u4f1a\u5f88\u6f2b\u957f\r\ndep init -v\r\n<\/code><button class=\"VJbwyy\" type=\"button\" aria-label=\"\u590d\u5236\u4ee3\u7801\"><i class=\"anticon anticon-copy\" aria-label=\"icon: copy\"><\/i><\/button><\/pre>\n<p>\u4f1a\u751f\u6210\u4e24\u4e2a\u6587\u4ef6\u00a0<code>Gopkg.lock<\/code>\u3001<code>Gopkg.toml<\/code>\u00a0\u548c\u4e00\u4e2a\u76ee\u5f55\u00a0<code>vendor<\/code><\/p>\n<blockquote><p>\u5982\u679c\u62a5\u9519\u00a0<code>Gopkg.toml and Gopkg.lock are out of sync<\/code>\u00a0\u9700\u8981\u6267\u884c\u4e00\u4e0b\u00a0<code>dep ensure -v<\/code><\/p><\/blockquote>\n<p>\u5176\u4e2d<\/p>\n<ul>\n<li><code>Gopkg.toml<\/code>\u00a0\u662f\u4f9d\u8d56\u7ba1\u7406\u7684\u6838\u5fc3\u6587\u4ef6\uff0c\u53ef\u4ee5\u751f\u6210\u4e5f\u53ef\u4ee5\u624b\u52a8\u4fee\u6539\uff0c<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgolang.github.io%2Fdep%2Fdocs%2FGopkg.toml.html\" target=\"_blank\" rel=\"noopener noreferrer\">Gopkg.toml \u5b98\u65b9\u6587\u6863<\/a><\/li>\n<li><code>Gopkg.lock<\/code>\u00a0\u662f\u751f\u6210\u7684\u6587\u4ef6\uff0c\u4e0d\u8981\u624b\u5de5\u4fee\u6539\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgolang.github.io%2Fdep%2Fdocs%2FGopkg.lock.html\" target=\"_blank\" rel=\"noopener noreferrer\">Gopkg.lock \u5b98\u65b9\u6587\u6863<\/a><\/li>\n<li><code>vendor<\/code>\u00a0\u76ee\u5f55\u662f golang1.5 \u4ee5\u540e\u4f9d\u8d56\u7ba1\u7406\u76ee\u5f55\uff0c\u8fd9\u4e2a\u76ee\u5f55\u7684\u4f9d\u8d56\u4ee3\u7801\u662f\u4f18\u5148\u52a0\u8f7d\u7684\uff0c\u7c7b\u4f3c node \u7684\u00a0<code>node_module<\/code>\u00a0\u76ee\u5f55<\/li>\n<\/ul>\n<h2>\u4f9d\u8d56\u7ba1\u7406<\/h2>\n<pre class=\"line-numbers  language-sh\"><code class=\"sh  language-sh\"># \u4f9d\u8d56\u7ba1\u7406\u5e2e\u52a9\r\ndep help ensure\r\n# \u6dfb\u52a0\u4e00\u6761\u4f9d\u8d56\r\ndep ensure -add github.com\/bitly\/go-simplejson\r\n# \u8fd9\u91cc @= \u53c2\u6570\u6307\u5b9a\u7684\u662f \u67d0\u4e2a tag\r\ndep ensure -add github.com\/bitly\/go-simplejson@=0.4.3\r\n# \u6dfb\u52a0\u540e\uff0c\u5148\u8c03\u7528\u4e00\u4e0b\u65b0\u52a0\u5165\u7684\u5e93\uff0c\u7136\u540e\u6267\u884c \u786e\u4fdd \u540c\u6b65\r\ndep ensure\r\n# \u540c\u7406\u5efa\u8bae\u4f7f\u7528\r\ndep ensure -v\r\n# \u66f4\u65b0\u4f9d\u8d56\r\ndep ensure -update -v\r\n#  \u5220\u9664\u6ca1\u6709\u7528\u5230\u7684 package\r\ndep prune -v\r\n<\/code><button class=\"VJbwyy\" type=\"button\" aria-label=\"\u590d\u5236\u4ee3\u7801\"><i class=\"anticon anticon-copy\" aria-label=\"icon: copy\"><\/i><\/button><\/pre>\n<blockquote><p>dep ensure -add \u6dfb\u52a0\u4f9d\u8d56\u540e\uff0c\u6ca1\u6709\u5728 vendor \u76ee\u5f55\u4e2d\uff0c\u662f\u56e0\u4e3a\u9700\u8981\u5728\u4ee3\u7801\u4e2d\u7528\u5230\u8fd9\u4e2a\u5e93\u624d\u80fd\u6b63\u786e\u6dfb\u52a0<br \/>\n\u6240\u4ee5\u5728\u6267\u884c dep ensure -add \u540e\uff0c\u5148\u5c1d\u8bd5\u4f7f\u7528\u4e00\u4e0b\u65b0\u6dfb\u52a0\u7684\u5e93\uff0c\u7136\u540e\u8fd0\u884c dep ensure -v<\/p><\/blockquote>\n<h3>\u4f9d\u8d56\u67e5\u770b<\/h3>\n<p>\u53ef\u4ee5\u4f7f\u7528\u00a0<code>dep status<\/code>\u00a0\u67e5\u770b\u5f53\u524d\u5de5\u7a0b\u7684\u4f9d\u8d56<\/p>\n<pre class=\"line-numbers  language-sh\"><code class=\"sh  language-sh\">$ dep status\r\nPROJECT CONSTRAINT VERSION REVISION LATEST PKGS USED\r\ngolang.org\/x\/net branch master branch master 461777f 3f473d3 4\r\ngolang.org\/x\/sys branch master branch master 93c9922 93c9922 2\r\ngolang.org\/x\/text v0.3.2 v0.3.2 342b2e1 v0.3.2 17\r\ngolang.org\/x\/tools branch master branch master f8d1dee d4e310b 4\r\ngopkg.in\/go-playground\/validator.v8 v8.18.2 v8.18.2 5f1438d v8.18.2 1\r\ngopkg.in\/yaml.v2 v2.2.2 v2.2.2 51d6538 v2.2.2 1\r\n$ dep status | grep gin\r\ngithub.com\/gin-contrib\/sse v0.1.0 v0.1.0 54d8467 v0.1.0 1\r\ngithub.com\/gin-gonic\/gin ^1.4.0 v1.4.0 b75d67c v1.4.0 4\r\ngithub.com\/swaggo\/gin-swagger branch master branch master dbf6ef4 ddb1576 2\r\n<\/code><button class=\"VJbwyy\" type=\"button\" aria-label=\"\u590d\u5236\u4ee3\u7801\"><i class=\"anticon anticon-copy\" aria-label=\"icon: copy\"><\/i><\/button><\/pre>\n<ul>\n<li>\u5982\u679c\u9700\u8981\u4f9d\u8d56\u56fe\u67e5\u770b\uff0c\u53ef\u4ee5\u501f\u52a9 graphviz \u5de5\u5177<\/li>\n<\/ul>\n<pre class=\"line-numbers  language-sh\"><code class=\"sh  language-sh\"># linux \u8bbe\u5907\r\n$ sudo apt-get install graphviz\r\n$ dep status -dot | dot -T png | display\r\n# macOS\r\n$ brew install graphviz\r\n$ dep status -dot | dot -T png | open -f -a \/Applications\/Preview.app\r\n# windows \u5148\u5b89\u88c5 chocolatey https:\/\/chocolatey.org\/\r\n&gt; choco install graphviz.portable\r\n&gt; dep status -dot | dot -T png -o status.png; start status.png\r\n<\/code><button class=\"VJbwyy\" type=\"button\" aria-label=\"\u590d\u5236\u4ee3\u7801\"><i class=\"anticon anticon-copy\" aria-label=\"icon: copy\"><\/i><\/button><\/pre>\n<h3>\u4f9d\u8d56\u7ea6\u675f\u89c4\u5219<\/h3>\n<p>\u6dfb\u52a0\u4f9d\u8d56\u5e38\u7528\u7684\u7528\u6cd5\u662f<\/p>\n<pre class=\"line-numbers  language-sh\"><code class=\"sh  language-sh\"># \u4f9d\u8d56\u6307\u5b9a\u7684\u7248\u672c 0.4.3\r\ndep ensure -add github.com\/bitly\/go-simplejson@=0.4.3\r\n# \u4f9d\u8d56\u5927\u4e8e\u7b49\u4e8e 0.4.3 \u7684\u7248\u672c\r\ndep ensure -add github.com\/bitly\/go-simplejson@^0.4.3\r\n<\/code><button class=\"VJbwyy\" type=\"button\" aria-label=\"\u590d\u5236\u4ee3\u7801\"><i class=\"anticon anticon-copy\" aria-label=\"icon: copy\"><\/i><\/button><\/pre>\n<blockquote><p>-add \u65f6\u53ef\u7528\u7684\u89c4\u5219\u8be6\u7ec6\u8bf4\u660e\u89c1,\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgolang.github.io%2Fdep%2Fdocs%2Fensure-mechanics.html%23add\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/golang.github.io\/dep\/docs\/ensure-mechanics.html#add<\/a><\/p><\/blockquote>\n<p>\u4f9d\u8d56\u66f4\u65b0\u7684\u89c4\u5219\uff0c\u5e38\u89c1\u7ea6\u675f\u89c1\u8868<\/p>\n<table>\n<thead>\n<tr>\n<th><code>GOPKG.TOML<\/code>\u00a0<strong>\u7248\u672c\u7ea6\u675f\u7c7b\u578b<\/strong><\/th>\n<th><strong>\u4f8b\u5b50<\/strong><\/th>\n<th><code>dep ensure -update<\/code>\u00a0<strong>\u884c\u4e3a<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>version<\/code>\u00a0(\u8bed\u4e49\u5316\u7248\u672c)<\/td>\n<td><code>\"^1.0.0\"<\/code><\/td>\n<td>\u8bd5\u56fe\u83b7\u5f97\u6700\u65b0\u53ef\u7528\u7248\u672c<\/td>\n<\/tr>\n<tr>\n<td>branch<\/td>\n<td><code>\"master\"<\/code><\/td>\n<td>\u8bd5\u56fe\u5207\u6362\u5230\u8fd9\u4e2a\u5206\u652f\u6700\u65b0\u63d0\u4ea4<\/td>\n<\/tr>\n<tr>\n<td><code>version<\/code>\u00a0(\u975e\u9650\u5b9a\u8bed\u4e49\u7248\u672c)<\/td>\n<td><code>\"=1.0.0\"<\/code><\/td>\n<td>\u53ea\u5728\u591a\u4e2a\u7248\u672c\u65f6\u624d\u66f4\u65b0\u4f9d\u8d56\u5230\u6307\u5b9a\u7248\u672c (e.g.\u00a0<code>git push --force &lt;tag&gt;<\/code>)<\/td>\n<\/tr>\n<tr>\n<td><code>version<\/code>\u00a0(\u975e\u8bed\u4e49\u7248\u672c)<\/td>\n<td><code>\"foo\"<\/code><\/td>\n<td>\u53ea\u5728\u591a\u4e2a\u7248\u672c\u65f6\u624d\u66f4\u65b0\u4f9d\u8d56\u7248\u672c<\/td>\n<\/tr>\n<tr>\n<td>revision<\/td>\n<td><code>aabbccd...<\/code><\/td>\n<td>\u4e0d\u4f1a\u66f4\u6539\u4f9d\u8d56<\/td>\n<\/tr>\n<tr>\n<td>(none)<\/td>\n<td>(none)<\/td>\n<td>\u6839\u636e\u7b2c\u4e00\u4e2a\u7248\u672c\u6765\uff0c\u53c2\u89c1\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgodoc.org%2Fgithub.com%2Fgolang%2Fdep%2Fgps%23SortForUpgrade\" target=\"_blank\" rel=\"noopener noreferrer\">\u4f9d\u8d56\u6392\u5e8f\u6587\u6863 the sort order<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote><p>-update \u7684\u89c4\u5219\uff0c\u8be6\u7ec6\u6587\u6863\u89c1\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgolang.github.io%2Fdep%2Fdocs%2Fensure-mechanics.html%23update\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/golang.github.io\/dep\/docs\/ensure-mechanics.html#update<\/a><\/p><\/blockquote>\n<h3>\u4f9d\u8d56\u66f4\u65b0<\/h3>\n<p>\u7f16\u8f91\u00a0<code>Gopkg.toml<\/code>\u00a0\u6587\u4ef6\uff0c\u914d\u7f6e\u65b0\u7684\u4f9d\u8d56\uff0c\u7136\u540e\u6267\u884c<\/p>\n<pre class=\"line-numbers  language-sh\"><code class=\"sh  language-sh\">dep ensure -update -v &amp;&amp; dep ensure -v\r\n<\/code><button class=\"VJbwyy\" type=\"button\" aria-label=\"\u590d\u5236\u4ee3\u7801\"><i class=\"anticon anticon-copy\" aria-label=\"icon: copy\"><\/i><\/button><\/pre>\n<blockquote><p>\u6ce8\u610f\uff0c\u8fd9\u4e2a\u548c\u66f4\u65b0\u4f9d\u8d56\u662f\u5b8c\u5168\u4e0d\u540c\u7684\u6982\u5ff5\uff0c\u56e0\u4e3a dep \u4f9d\u8d56\u00a0<code>vendor<\/code>\u00a0\u76ee\u5f55\uff0c\u6240\u4ee5\u4f1a\u51fa\u73b0\u4e00\u79cd\u5947\u602a\u7684\u60c5\u51b5<br \/>\ntoml \u6587\u4ef6\u4fee\u6539\u4e86\uff0c\u4f46\u662f\u4f9d\u8d56\u6ca1\u6709\u5728 vendor \u76ee\u5f55\u51fa\u73b0\uff0c\u8fd9\u70b9\u4f60\u9700\u8981\u5b66\u4e60 node_module \u4fee\u590d\u5927\u6cd5<br \/>\n\u5220\u9664 vendor \u76ee\u5f55\u4e2d\u5bf9\u5e94\u7684\u5185\u5bb9\uff0c\u6216\u8005\u5e72\u6389\u6574\u4e2a vendor \u76ee\u5f55<\/p>\n<blockquote><p>\u53c2\u8003\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgolang.github.io%2Fdep%2Fdocs%2Ffailure-modes.html%23vendor-write-errors\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/golang.github.io\/dep\/docs\/failure-modes.html#vendor-write-errors<\/a><\/p><\/blockquote>\n<\/blockquote>\n<h3>\u4f9d\u8d56\u7ba1\u7406\u7f13\u5b58\u9519\u8bef<\/h3>\n<p>dep \u7684\u4f9d\u8d56\u7ba1\u7406\u4f1a\u4f7f\u7528\u672c\u5730\u7f13\u5b58\uff0c\u7f13\u5b58\u76ee\u5f55\u662f\u00a0<code>$GOPATH\/pkg\/dep\/sources<\/code><br \/>\n\u51fa\u73b0\u67d0\u4e9b\u7248\u672c\u51b2\u7a81\u95ee\u9898\u65f6\uff0c\u53ef\u4ee5\u5220\u9664\u8fd9\u4e2a\u7f13\u5b58\u6765\u89e3\u51b3\u95ee\u9898<\/p>\n<blockquote><p>\u53c2\u8003\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgolang.github.io%2Fdep%2Fdocs%2Ffailure-modes.html%23bad-local-cache-state\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/golang.github.io\/dep\/docs\/failure-modes.html#bad-local-cache-state<\/a><\/p><\/blockquote>\n<h2>dep \u7ba1\u7406\u5b58\u5728\u7684\u95ee\u9898<\/h2>\n<ul>\n<li>\u8fdc\u7a0b\u4ed3\u5e93\u62c9\u53d6\u4f1a\u6bd4\u8f83\u56f0\u96be\uff0c\u6bd4\u5982 golang.org \u7684\uff0c\u8fd9\u4e2a\u4f60\u5f97\u81ea\u5df1\u60f3\u529e\u6cd5\uff0c\u6bd4\u5982\u4f7f\u7528\u955c\u50cf\uff0c\u6216\u8005\u628a\u4f9d\u8d56\u6254\u00a0<code>vendor \u76ee\u5f55<\/code><\/li>\n<li>\u56e0\u4e3a\u53ef\u4ee5\u53d1\u73b0<code>\u8de8\u6a21\u5757\u7684\u4ee3\u7801\u62f7\u8d1d<\/code>\uff0c\u5bfc\u81f4\u62c9\u53d6\u4f9d\u8d56\u5931\u8d25\uff0c\u56e0\u4e3a dep \u662f\u62f7\u8d1d\u4ed3\u5e93\u4ee3\u7801\uff0c\u62a5\u9519\u4f1a\u6bd4\u8f83\u6478\u4e0d\u5230\u5934\u8111\uff0c\u5efa\u8bae\u4ed4\u7ec6\u6bd4\u5bf9\u65e5\u5fd7<\/li>\n<li>\u56e0\u4e3a go \u7684\u4f9d\u8d56\u7ba1\u7406\u5b9e\u9645\u5c31\u662f git \u7684\u4ed3\u5e93\u62c9\u53d6\uff0c\u5982\u679c<code>\u4f9d\u8d56\u7684\u4ed3\u5e93\u6ca1\u6709\u6253 tag<\/code>, \u90a3\u4e48dep \u4f1a\u4f7f\u7528\u79bb HEAD \u63d0\u4ea4\u6700\u8fd1\u7684\u4e00\u6b21 tag<br \/>\n\u5bfc\u81f4\u7f16\u8bd1\u7ecf\u5e38\u4e0d\u901a\u8fc7<\/li>\n<\/ul>\n<p>\u4e34\u65f6\u89e3\u51b3\u65b9\u6cd5\u662f\u4fee\u6539\u00a0<code>Gopkg.toml<\/code>\u00a0\u5c06\u6709\u95ee\u9898\u7684\u4ed3\u5e93\u00a0<code>version<\/code>\u00a0\u6ce8\u91ca\u6389\uff0c<code>branch<\/code>\u00a0\u5207\u6362\u5230\u53ef\u4ee5\u7684\u5206\u652f<\/p>\n<pre class=\"line-numbers  language-toml\"><code class=\"toml  language-toml\">[[constraint]]\r\n  branch = \"master\"\r\n  name = \"github.com\/xx\/xxx\"\r\n  #version = \"\"\r\n<\/code><button class=\"VJbwyy\" type=\"button\" aria-label=\"\u590d\u5236\u4ee3\u7801\"><i class=\"anticon anticon-copy\" aria-label=\"icon: copy\"><\/i><\/button><\/pre>\n<p>\u6700\u597d\u7684\u65b9\u6cd5\u8fd8\u662f\u7ed9\u4f9d\u8d56\u4ed3\u5e93\u6253 tag<\/p>\n<h1>\u6301\u7eed\u96c6\u6210\u4f7f\u7528 dep \u7ba1\u7406\u4f9d\u8d56<\/h1>\n<blockquote><p>\u8fd9\u91cc\u5c31\u4e0d\u4ecb\u7ecd\u4e00\u4e2a dep \u7ba1\u7406\u5b9e\u4f8b\u4e86\uff0c\u56e0\u4e3a\u73af\u5883\u4e0d\u4e00\u6837\uff0c\u4f7f\u7528\u7684CI CD\u94fe\u4e0d\u4e00\u6837\uff0c\u9664\u4e86\u811a\u672c\u53ef\u4ee5\u901a\u7528\uff0c\u5176\u4ed6\u5185\u5bb9\u90fd\u8d85\u8fc7\u4e86\u672c\u6587\u7684\u8303\u56f4\uff0c\u6240\u4ee5\u4e3b\u8981\u8bb2\u4e9b\u539f\u5219\u4e0a\u7684\u4e8b\u60c5<\/p><\/blockquote>\n<p>\u6301\u7eed\u96c6\u6210\u65f6\uff0c\u4f7f\u7528 dep \u7684\u57fa\u672c\u539f\u5219<\/p>\n<ul>\n<li>\u5c3d\u91cf<code>\u4f7f\u7528 tag \u4f5c\u4e3a\u7248\u672c\u53f7<\/code>\uff0c\u4e0d\u4f7f\u7528\u5206\u652f\uff08tag \u5c31\u662f\u4e0d\u53ef\u7ef4\u62a4\u5206\u652f\uff0c\u80fd\u56fa\u5316\u7248\u672c\uff0c\u5206\u652f\u6ca1\u6709\u8fd9\u4e2a\u80fd\u529b\uff09<\/li>\n<li>\u7981\u6b62\u975e\u00a0<code>vendor<\/code>\u00a0\u4f9d\u8d56\u65b9\u5f0f\u7f16\u8bd1<\/li>\n<li><code>\u4f7f\u7528 Makefile \u6216\u8005 shell \u63a7\u5236\u96c6\u6210\u8fc7\u7a0b<\/code><\/li>\n<li><code>\u53c2\u6570\u5316\u90e8\u7f72\u63a7\u5236<\/code>\uff0c\u505a\u597d \u6d4b\u8bd5 \u7070\u5ea6 \u751f\u4ea7\u7684\u5206\u79bb\uff0c\u8fd9\u91cc\u63a8\u8350\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgithub.com%2Fspf13%2Fviper\" target=\"_blank\" rel=\"noopener noreferrer\">viper<\/a>\u00a0\u53c2\u6570\u914d\u7f6e\u5de5\u5177<\/li>\n<\/ul>\n<h2>\u4ee3\u7801\u63d0\u4ea4\u7248\u672c\u7ba1\u7406<\/h2>\n<ul>\n<li><code>Gopkg.toml<\/code>\u00a0\u548c\u00a0<code>Gopkg.lock<\/code>\u00a0\u5168\u90e8\u00a0<code>vendor<\/code>\u00a0\u76ee\u5f55\u90fd\u63d0\u4ea4\uff0cgit \u4ed3\u5e93\u538b\u529b\u5f88\u5927\uff0c\u4f46\u662f\u53ef\u4ee5\u505a\u5230\u51cf\u5c11\u8fdc\u7a0b\u4f9d\u8d56<\/li>\n<\/ul>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u505a\u5230\u5f00\u7bb1\u5373\u7528<\/p>\n<ul>\n<li>\u8ba9\u5de5\u7a0b\u53ea\u4fdd\u7559\u00a0<code>Gopkg.toml<\/code>\u00a0\u548c\u00a0<code>Gopkg.lock<\/code>\uff0c\u51cf\u5c11\u4ed3\u5e93\u4ee3\u7801\u5927\u5c0f\uff0c\u964d\u4f4e\u4ed3\u5e93\u538b\u529b<\/li>\n<\/ul>\n<p>\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6bcf\u6b21\u6784\u5efa\u5c31\u5f97\u6267\u884c\u00a0<code>dep ensure -v<\/code><\/p>\n<blockquote><p>\u6211\u503e\u5411\u4e8e\u9009\u62e9\u63d0\u4ea4\u5168\u90e8\u00a0<code>vendor<\/code>, \u539f\u56e0\u662f\u8fdc\u7a0b\u4ed3\u5e93\u7684\u4f9d\u8d56\u62c9\u53d6\u975e\u5e38\u6162\uff0c\u5bb9\u6613\u62d6\u6162\u6784\u5efa<br \/>\n\u5982\u679cgit \u4ed3\u5e93\u538b\u529b\u5f88\u5927\uff0c\u53ef\u4ee5\u505a\u7f13\u5b58\u4ed3\u5e93\u8fc1\u79fb\u5206\u79bb\u538b\u529b\uff0c\u5f53\u7136\u5f97\u5199\u811a\u672c\u6279\u91cf\u4fee\u6539 golang \u4ee3\u7801\u7684\u5f15\u7528<\/p>\n<blockquote><p>\u5f53\u7136\u4f60\u8fd8\u6709\u4e00\u4e2a\u9009\u62e9\uff0c\u5c06 vendor \u505a\u6210\u4e00\u4e2a\u5171\u4eab\u76ee\u5f55\uff0c\u7f16\u8bd1\u65f6\u6302\u8f7d\u5230\u7f16\u8bd1\u5de5\u7a0b\uff0c\u8fd9\u6837\u65e2\u8ba9 git \u4ed3\u5e93\u7684\u538b\u529b\u53d8\u5c0f\uff0c\u4e5f\u4e0d\u88ab\u8fdc\u7a0b\u4ed3\u5e93\u7f51\u901f\u95ee\u9898\u56f0\u6270\uff0c\u7f3a\u70b9\u5c31\u662f\u5f97\u989d\u5916\u7ef4\u62a4\u811a\u672c<\/p><\/blockquote>\n<\/blockquote>\n<h2>\u6784\u5efa\u8fc7\u7a0b\u7684\u63a7\u5236<\/h2>\n<ul>\n<li>\u56e0\u4e3a ${GOPATH} \u73af\u5883\u53d8\u91cf\u7684\u7279\u6b8a\u6027\uff0c<code>\u4e0d\u5efa\u8bae\u76f4\u63a5\u4f7f\u7528\u7c7b\u4f3c jenkins \u8fd9\u79cd\u865a\u62df\u547d\u4ee4\u884c\u6784\u5efa<\/code>\uff0c\u5bb9\u6613\u5bfc\u81f4\u5404\u79cd\u6df7\u4e71\uff08\u590d\u6570GOPATH\uff0c\u867d\u7136\u53ef\u884c\uff0c\u4f46\u5b58\u5728\u73af\u5883\u4e32\u6270\uff0c\u964d\u4f4e\u7f16\u8bd1\u901f\u5ea6\uff0c\u751a\u81f3\u62a5\u9519\u7684\u95ee\u9898\uff09<\/li>\n<li>\u4f7f\u7528 docker \u4e34\u65f6\u5bb9\u5668\u6784\u5efa\uff0c<code>\u8f93\u51fa\u6784\u5efa\u7684\u76ee\u6807\u4e8c\u8fdb\u5236\u548c\u62a5\u544a<\/code>\u4f5c\u4e3a\u7ed3\u679c\u662f\u6700\u597d\u7684\u9009\u62e9<\/li>\n<li>\u5982\u679c\u662f\u670d\u52a1\u578b\u7684\u6784\u5efa\uff0c\u53ef\u4ee5<code>\u76f4\u63a5\u4f7f\u7528 docker \u5bb9\u5668\u7f16\u6392\u6d4b\u8bd5\u670d\u52a1<\/code><\/li>\n<\/ul>\n<blockquote><p>docker\u5bb9\u5668\u670d\u52a1\u6784\u5efa\u6837\u4f8b\u00a0<a href=\"https:\/\/links.jianshu.com\/go?to=https%3A%2F%2Fgithub.com%2Fbridgewwater%2Fdocker-beego-temple%2Fblob%2Fmaster%2FREADME_CN.md\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/bridgewwater\/docker-beego-temple<\/a><\/p><\/blockquote>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u5730\u5740 [TOC] \u4ecb\u7ecd go dep<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[122],"class_list":["post-3977","post","type-post","status-publish","format-standard","hentry","tag-06-godocker"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/3977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=3977"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/3977\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=3977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=3977"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=3977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}