<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: goproxy.dev</title>
    <description>The latest articles on DEV Community by goproxy.dev (@goproxydev).</description>
    <link>https://dev.to/goproxydev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1927270%2Fd3f01cdb-ab29-472e-a717-bc3f0eb19258.png</url>
      <title>DEV Community: goproxy.dev</title>
      <link>https://dev.to/goproxydev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/goproxydev"/>
    <language>en</language>
    <item>
      <title>Easily manage and install your private Go modules</title>
      <dc:creator>goproxy.dev</dc:creator>
      <pubDate>Mon, 19 Aug 2024 13:21:19 +0000</pubDate>
      <link>https://dev.to/goproxydev/easily-manage-and-install-your-private-go-modules-g74</link>
      <guid>https://dev.to/goproxydev/easily-manage-and-install-your-private-go-modules-g74</guid>
      <description>&lt;p&gt;For Golang developers, managing and installing Go modules is usually straightforward when dealing with public repositories. However, things get more tricky when you need to work with private Go modules.&lt;/p&gt;

&lt;p&gt;The Go modules toolchain doesn't provide a built-in mechanism for working with private modules beyond &lt;a href="https://go.dev/ref/mod#private-module-proxy-private" rel="noopener noreferrer"&gt;using a private GOPROXY&lt;/a&gt;, and properly setting up and maintaining one is not an option for every developer or organization. Some package repository services support working with private Go modules but generally don't provide the cleanest experience for developers.&lt;/p&gt;

&lt;p&gt;For this reason, in most cases, we end up arranging intricate Git configurations (.netrc or .gitconfig) &lt;a href="https://go.dev/ref/mod#private-modules" rel="noopener noreferrer"&gt;combined with some Go environment variables&lt;/a&gt; to manage authentication with our private repositories when using &lt;code&gt;go get&lt;/code&gt;, &lt;code&gt;go install&lt;/code&gt;, or &lt;code&gt;go mod download&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The problem with these Git configurations is that they are not evident to all developers, and they may be insecure since can require storing plain-text credentials in the filesystem. These issues become even more problematic when configuring CI/CD systems, building Docker images, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing &lt;a href="https://goproxy.dev" rel="noopener noreferrer"&gt;goproxy.dev&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;As long-time Golang developers (coming from the age when &lt;a href="https://github.com/tools/godep" rel="noopener noreferrer"&gt;Go modules didn't even exist&lt;/a&gt;), we've always dreamed of a time when working with private Go libraries would be as easy and powerful as working with public ones.&lt;/p&gt;

&lt;p&gt;Imagine developing and pushing your private Go libraries to GitHub, and immediately &lt;code&gt;go get -u&lt;/code&gt; the new changes from your project source code by only setting the &lt;code&gt;GOPROXY&lt;/code&gt; environment variable. No tricky and insecure Git configurations, no self-hosted GOPROXY maintenance, no complex and error-prone publishing workflows, and the same setup for your local dev machine, Dockerfile, and CI/CD environment.&lt;/p&gt;

&lt;p&gt;Say hello to goproxy.dev, a &lt;a href="https://goproxy.dev" rel="noopener noreferrer"&gt;private GOPROXY service that integrates with GitHub&lt;/a&gt; to provide you with &lt;em&gt;seamless Go private modules installation&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to set up goproxy.dev in your development workflow
&lt;/h2&gt;

&lt;p&gt;Just &lt;a href="https://goproxy.dev" rel="noopener noreferrer"&gt;sign in into goproxy.dev with your GitHub account&lt;/a&gt;, give access to the private repositories you'll use, and export your &lt;code&gt;GOPROXY&lt;/code&gt; and &lt;code&gt;GONOSUMDB&lt;/code&gt; environment variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;GOPROXY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;TOKEN@proxy.goproxy.dev,proxy.golang.org,direct
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;GONOSUMDB&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;github.com/your-organization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;These Go environment variables can be set directly from your shell config (.zshrc, .bashrc, etc.) or using &lt;code&gt;go env -w&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then you can run your usual go commands to install and download your private modules.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go get github.com/your-organization/go-module@v2.0.0
go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/your-organization/go-module/cmd
...
go mod download
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to use goproxy.dev to build Docker images
&lt;/h3&gt;

&lt;p&gt;Integrating with goproxy.dev only requires setting up two environment variables. The best way to do so during a Docker build is by using the &lt;a href="https://docs.docker.com/build/building/secrets/" rel="noopener noreferrer"&gt;Docker build secrets&lt;/a&gt; feature.&lt;/p&gt;

&lt;p&gt;Inside your Dockerfile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; go.mod go.sum ./&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nt"&gt;--mount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;secret,id&lt;span class="o"&gt;=&lt;/span&gt;GOPROXY &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="nv"&gt;GOPROXY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /run/secrets/GOPROXY&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="se"&gt;\
&lt;/span&gt;    &lt;span class="nv"&gt;GONOSUMDB&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;github.com/your-organization &lt;span class="se"&gt;\
&lt;/span&gt;    go mod download
&lt;span class="k"&gt;RUN &lt;/span&gt;go build .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;GOPROXY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"[your GOPROXY value]"&lt;/span&gt; docker build &lt;span class="nt"&gt;--secret&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;GOPROXY
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to use goproxy.dev from GitHub Actions
&lt;/h3&gt;

&lt;p&gt;Just &lt;a href="https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions" rel="noopener noreferrer"&gt;configure a secret for your GitHub Actions&lt;/a&gt; containing your GOPROXY URL and use it from your workflows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
        &lt;span class="s"&gt;go mod download&lt;/span&gt;
        &lt;span class="s"&gt;go build .&lt;/span&gt;
      &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;GOPROXY&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.PRIVATE_GOPROXY }}&lt;/span&gt;
        &lt;span class="na"&gt;GONOSUMDB&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;github.com/your-organization&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
   Simplify your Go development workflow today
&lt;/h2&gt;

&lt;p&gt;With &lt;a href="https://goproxy.dev" rel="noopener noreferrer"&gt;goproxy.dev&lt;/a&gt; you'll have the best developer experience when consuming libraries with Go. Whether you depend on open-source public libraries or private modules from your organization, you'll have a unified workflow: set up your &lt;code&gt;GOPROXY&lt;/code&gt; environment variable, and &lt;code&gt;go get&lt;/code&gt; dependencies for a specific version, Git branch, or commit.&lt;/p&gt;

&lt;p&gt;Learn more and get started with &lt;a href="https://goproxy.dev" rel="noopener noreferrer"&gt;goproxy.dev&lt;/a&gt; today by signing up for our 14-day free trial.&lt;/p&gt;

</description>
      <category>go</category>
      <category>github</category>
      <category>docker</category>
      <category>cicd</category>
    </item>
  </channel>
</rss>
