<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Dep - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Dep - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 25 May 2026 15:49:19 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/dep/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ An intro to dep: How to manage your Golang project dependencies ]]>
                </title>
                <description>
                    <![CDATA[ By Ying Kit Yuen Update @ 2018–11–26: Technology is not just moving at a breakneck speed but also changing rapidly. Within a year, this article is OUTDATED! And according to the dep project page: dep was the “official experiment.” The Go toolchain, ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/an-intro-to-dep-how-to-manage-your-golang-project-dependencies-7b07d84e7ba5/</link>
                <guid isPermaLink="false">66c343fb0bafa8455505c673</guid>
                
                    <category>
                        <![CDATA[ Dep ]]>
                    </category>
                
                    <category>
                        <![CDATA[ glide ]]>
                    </category>
                
                    <category>
                        <![CDATA[ golang ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 02 Feb 2018 20:23:34 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*nPaOoEou7T-cM9WZGtU-gg.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Ying Kit Yuen</p>
<p><strong>Update @ 2018–11–26: Technology is not just moving at a breakneck speed but also changing rapidly. Within a year, this article is OUTDATED!</strong></p>
<p>And according to the <a target="_blank" href="https://github.com/golang/dep">dep project page</a>:</p>
<blockquote>
<p><em>dep was the “official experiment.” The Go toolchain, as of 1.11, has (experimentally) adopted an approach that sharply diverges from dep. As a result, we are continuing development of dep, but gearing work primarily towards the development of an alternative prototype for versioning behavior in the toolchain.</em></p>
</blockquote>
<p>For more information about the new Go build-in management, please refer to the official GitHub Wiki — <a target="_blank" href="https://github.com/golang/go/wiki/Modules">Go 1.11 Modules</a>.</p>
<p>Thanks <a target="_blank" href="https://twitter.com/bitfield">John Arundel @bitfield</a> and <a target="_blank" href="https://twitter.com/yakuter">Erhan Yakut @yakuter</a> for revealing the problem. ?</p>
<p>—</p>
<p><strong>Update @ 2018–02–03: <a target="_blank" href="https://medium.com/@sdboyer">Sam Boyer</a> from the godep team has clarified some incorrect information in this article. I apologize to <a target="_blank" href="https://medium.com/@sdboyer">Sam Boyer</a> and the readers for any inconvenience.</strong> ?</p>
<p>—</p>
<p>Previously, I posted an <a target="_blank" href="https://blog.boatswain.io/post/manage-go-dependencies-using-glide/">article</a> about dependency management in <a target="_blank" href="https://golang.org/">Go</a> using <a target="_blank" href="https://glide.sh/">Glide.</a> I got a feedback that <a target="_blank" href="https://glide.sh/">Glide</a> will become obsolete. The <a target="_blank" href="https://glide.sh/">Glide</a> team is suggesting users move to another dependency management tool called <a target="_blank" href="https://github.com/golang/dep">dep</a> written by the <a target="_blank" href="https://github.com/golang">Golang</a> team.</p>
<blockquote>
<p>The Go community now has the dep project to manage dependencies. Please consider trying to migrate from Glide to dep. Glide will continue to be supported for some time but is considered to be in a state of support rather than active feature development.</p>
</blockquote>
<p>There is a plan about integrating <a target="_blank" href="https://github.com/golang/dep">dep</a> into the toolchain in <a target="_blank" href="https://tip.golang.org/doc/go1.10">Go 1.10 release</a>, but seems <a target="_blank" href="https://www.reddit.com/r/golang/comments/7dd2ty/go_110_release_notes_draft/#thing_t1_dpwyj4i">it still has a way to go</a>.</p>
<p><strong>Update @ 2018–02–03:</strong></p>
<ul>
<li><a target="_blank" href="https://github.com/golang/dep"><strong>dep</strong></a> <strong>is officially released.</strong></li>
<li><a target="_blank" href="https://github.com/golang/dep"><strong>dep</strong></a> <strong>is not moving into the toolchain with 1.10. please refer to the <a target="_blank" href="https://github.com/golang/dep/wiki/Roadmap">roadmap</a> for the latest information.</strong></li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*-jTtAekDfSoJn1uDzeyFVg.jpeg" alt="Image" width="541" height="398" loading="lazy">
<em>And I am just not fast enough. ?</em></p>
<h3 id="heading-create-the-project-inside-gopath">Create the project inside $GOPATH</h3>
<p>The project folder has to be inside <em>$GOPATH</em> in order to resolve the <a target="_blank" href="https://golang.org/">Go</a>package paths. Let’s create a new project at <em>$GOPATH/src/gitlab.com/ykyuen/dep-example</em> and add the following file.</p>
<p><strong>main.go</strong></p>
<h3 id="heading-the-dep-way">The dep way</h3>
<h4 id="heading-gopkgtoml-and-gopkglock">Gopkg.toml and Gopkg.lock</h4>
<p><a target="_blank" href="https://github.com/golang/dep">dep</a> reads two files called <em>Gopkg.toml</em> and the <em>Gopkg.lock</em>. Let’s initialize these 2 files using the <em>dep init</em> command.</p>
<pre><code>[ykyuen@camus dep-example]$ dep init  Using master <span class="hljs-keyword">as</span> constraint <span class="hljs-keyword">for</span> direct dep github.com/dustin/go-humanize  Locking <span class="hljs-keyword">in</span> master (bb3d318) <span class="hljs-keyword">for</span> direct dep github.com/dustin/go-humanize
</code></pre><p>As you can see, the <em>dep init</em> command scans the source codes and downloads all the packages needed for the project into the <em>vendor</em> folder.</p>
<p>The <em>Gopkg.lock</em> serves exactly the same function as the <em>glide.lock</em> file. It locks the version of the packages <strong>EXCEPT</strong> the version should be maintained in the <em>Gopkg.toml</em>. In short, the <em>Gopkg.lock</em> file is auto-generated and it depends on the <em>import</em> statements in the source version controlled by <em>Gopkg.toml</em>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*4rou4TKFvTSHxo_OSLp4jg.png" alt="Image" width="800" height="331" loading="lazy"></p>
<h4 id="heading-update-dependencys-version">Update dependency’s version</h4>
<p>Let’s edit the <em>Gopkg.toml</em> and use a slightly older version of the <a target="_blank" href="https://github.com/dustin/go-humanize">go-humanize</a> package instead of the latest master branch.</p>
<p>Then run <em>dep ensure</em> to update the package to the desired version. The following is the diff of the updated <em>Gopkg.lock</em>.</p>
<h4 id="heading-add-a-new-dependency">Add a new dependency</h4>
<p>New package could be added using the <em>dep ensure -add</em> command.</p>
<pre><code>[ykyuen@camus dep-example]$ dep ensure -add github.com/leekchan/accountingFetching sources...
</code></pre><pre><code><span class="hljs-string">"github.com/leekchan/accounting"</span> is not imported by your project, and has been temporarily added to Gopkg.lock and vendor/.If you run <span class="hljs-string">"dep ensure"</span> again before actually importing it, it will disappear <span class="hljs-keyword">from</span> Gopkg.lock and vendor/.
</code></pre><p>Now we have the new <em>accounting</em> package ready in the <em>vendor</em> folder with new constraints written to <em>Gopkg.toml</em> and locked in <em>Gopkg.lock</em>. Let’s update the <em>main.go</em> as follow.</p>
<p><strong>main.go</strong></p>
<p>And run it.</p>
<pre><code>[ykyuen@camus dep-example]$ go run main.gohello worldThat file is <span class="hljs-number">83</span> MB.You<span class="hljs-string">'re my 193rd best friend.You owe $6,582,491.$123,456,789.21$12,345,678.00$25,925,925.67-$25,925,925.67$123,456,789.21</span>
</code></pre><h3 id="heading-the-issue-with-git-submodule">The issue with git submodule</h3>
<p>One major difference of <a target="_blank" href="https://github.com/golang/dep">dep</a> compared to <a target="_blank" href="https://glide.sh/">Glide</a> is the package’s submodule is ignored. For example, after adding the <a target="_blank" href="https://github.com/go-goracle/goracle">go-goracle/goracle</a> package by <a target="_blank" href="https://github.com/golang/dep">dep</a>, the <a target="_blank" href="https://oracle.github.io/odpi/">odpi</a> submodule inside is empty and leads to error. The reason for dropping the submodule could be found at the following link.</p>
<ul>
<li><a target="_blank" href="https://github.com/golang/dep/issues/1240">Are there any plans to add Git submodules support?</a></li>
</ul>
<p><strong>Update @ 2018–02–03:</strong></p>
<p><strong>The paragraph about Git submodules is incorrect.</strong></p>
<p><a target="_blank" href="https://github.com/sdboyer"><strong>Sam Boyer</strong></a> <strong>wrote:</strong></p>
<blockquote>
<p><em>dep should be perfectly fine at pulling in git submodules in the case you describe. I just replicated what you describe here locally, and the problem isn’t submodules — it’s that there’s no Go code in github.com/go-goracle/goracle/odpi, so it can’t be imported directly.</em></p>
<p><em>You likely need to turn off unused-packages pruning in Gopkg.toml for that project specifically, as otherwise dep ensure will automatically remove what appears to be an unused directly (but it seems it’s actually used by cgo).</em></p>
</blockquote>
<p><strong>Update @ 2018–03–04:</strong></p>
<p>It is found that the <a target="_blank" href="https://github.com/go-goracle/goracle">go-goracle/goracle</a> package doesn’t work with <a target="_blank" href="https://github.com/golang/dep">dep</a>. You could follow the issue below and check the latest update from the <a target="_blank" href="https://github.com/golang/dep">dep</a> team.</p>
<ul>
<li><a target="_blank" href="https://github.com/golang/dep/issues/1633">Fail to get git submodule of a package after the dep ensure command</a></li>
</ul>
<h3 id="heading-summary">Summary</h3>
<ul>
<li>d̶̵̶e̶̵̶p̶̵̶ ̶̵̶i̶̵̶s̶̵̶ ̶̵̶q̶̵̶u̶̵̶i̶̵̶t̶̵̶e̶̵̶ ̶̵̶l̶̵̶i̶̵̶k̶̵̶e̶̵̶l̶̵̶y̶̵̶ ̶̵̶t̶̵̶o̶̵̶ ̶̵̶b̶̵̶e̶̵̶ ̶̵̶t̶̵̶h̶̵̶e̶̵̶ ̶̵̶o̶̵̶f̶̵̶f̶̵̶i̶̵̶c̶̵̶i̶̵̶a̶̵̶l̶̵̶ ̶̵̶d̶̵̶e̶̵̶p̶̵̶e̶̵̶n̶̵̶d̶̵̶e̶̵̶n̶̵̶c̶̵̶y̶̵̶ ̶̵̶m̶̵̶a̶̵̶n̶̵̶a̶̵̶g̶̵̶e̶̵̶m̶̵̶e̶̵̶n̶̵̶t̶̵̶ ̶̵̶t̶̵̶o̶̵̶o̶̵̶l̶̵̶ ̶̵̶i̶̵̶n̶̵̶ ̶̵̶t̶̵̶h̶̵̶e̶̵̶ ̶̵̶G̶̵̶o̶̵̶l̶̵̶a̶̵̶n̶̵̶g̶̵̶ ̶̵̶c̶̵̶o̶̵̶m̶̵̶m̶̵̶u̶̵̶n̶̵̶i̶̵̶t̶̵̶y̶̵̶.̶̵̶</li>
<li>I̶̵̶f̶̵̶ ̶̵̶y̶̵̶o̶̵̶u̶̵̶ ̶̵̶a̶̵̶r̶̵̶e̶̵̶ ̶̵̶s̶̵̶t̶̵̶a̶̵̶r̶̵̶t̶̵̶i̶̵̶n̶̵̶g̶̵̶ ̶̵̶a̶̵̶ ̶̵̶n̶̵̶e̶̵̶w̶̵̶ ̶̵̶G̶̵̶o̶̵̶l̶̵̶a̶̵̶n̶̵̶g̶̵̶ ̶̵̶p̶̵̶r̶̵̶o̶̵̶j̶̵̶e̶̵̶c̶̵̶t̶̵̶,̶̵̶ ̶̵̶d̶̵̶e̶̵̶p̶̵̶ ̶̵̶i̶̵̶s̶̵̶ ̶̵̶g̶̵̶o̶̵̶o̶̵̶d̶̵̶ ̶̵̶t̶̵̶o̶̵̶ ̶̵̶g̶̵̶o̶̵̶.̶̵̶</li>
<li>I̶f̶ ̶y̶o̶u̶ ̶a̶r̶e̶ ̶u̶s̶i̶n̶g̶ ̶G̶l̶i̶d̶e̶ ̶i̶n̶ ̶a̶ ̶l̶e̶g̶a̶c̶y̶ ̶p̶r̶o̶j̶e̶c̶t̶.̶ ̶Y̶o̶u̶ ̶c̶o̶u̶l̶d̶ ̶c̶o̶n̶s̶i̶d̶e̶r̶ ̶m̶i̶g̶r̶a̶t̶i̶n̶g̶ ̶t̶o̶ ̶d̶e̶p̶ ̶b̶u̶t̶ ̶i̶ ̶t̶h̶i̶n̶k̶ ̶t̶h̶e̶r̶e̶ ̶i̶s̶ ̶n̶o̶ ̶h̶a̶r̶m̶ ̶t̶o̶ ̶k̶e̶e̶p̶ ̶u̶s̶i̶n̶g̶ ̶G̶l̶i̶d̶e̶ ̶f̶o̶r̶ ̶a̶ ̶w̶h̶i̶l̶e̶ ̶u̶n̶t̶i̶l̶ ̶d̶e̶p̶ ̶i̶s̶ ̶o̶f̶f̶i̶c̶i̶a̶l̶l̶y̶ ̶r̶e̶l̶e̶a̶s̶e̶d̶.̶</li>
<li>I̶n̶ ̶a̶d̶d̶i̶t̶i̶o̶n̶,̶ ̶m̶i̶s̶s̶i̶n̶g̶ ̶p̶a̶c̶k̶a̶g̶e̶’̶s̶ ̶s̶u̶b̶m̶o̶d̶u̶l̶e̶ ̶m̶a̶y̶ ̶r̶e̶s̶u̶l̶t̶ ̶i̶n̶ ̶m̶a̶l̶f̶u̶n̶c̶t̶i̶o̶n̶ ̶o̶f̶ ̶y̶o̶u̶r̶ ̶c̶o̶d̶e̶.̶</li>
<li><a target="_blank" href="https://github.com/golang/dep"><strong>dep</strong></a> <strong>is officially released.</strong></li>
<li><a target="_blank" href="https://github.com/golang/dep"><strong>dep</strong></a> <strong>works well on pulling git submodule.</strong></li>
<li>Use standard library wherever possible. (Suggested by <a target="_blank" href="https://www.freecodecamp.org/news/an-intro-to-dep-how-to-manage-your-golang-project-dependencies-7b07d84e7ba5/undefined">philoserf</a>)</li>
<li>You can checkout this example on <a target="_blank" href="https://gitlab.com/ykyuen/dep-example">gitlab.com</a>.</li>
</ul>
<p>— Originally posted on <a target="_blank" href="https://blog.boatswain.io/post/manage-go-dependencies-using-dep/">Boatswain Blog</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
