<?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: Jai Pradeesh</title>
    <description>The latest articles on DEV Community by Jai Pradeesh (@jaipradeesh).</description>
    <link>https://dev.to/jaipradeesh</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%2F184237%2Fb6dfb5cb-c238-4ab9-9484-36a03932eb56.jpeg</url>
      <title>DEV Community: Jai Pradeesh</title>
      <link>https://dev.to/jaipradeesh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jaipradeesh"/>
    <language>en</language>
    <item>
      <title>Good First Issue - Make your first open-source contribution</title>
      <dc:creator>Jai Pradeesh</dc:creator>
      <pubDate>Tue, 18 Feb 2020 03:43:04 +0000</pubDate>
      <link>https://dev.to/deepsource/good-first-issue-make-your-first-open-source-contribution-ob6</link>
      <guid>https://dev.to/deepsource/good-first-issue-make-your-first-open-source-contribution-ob6</guid>
      <description>&lt;p&gt;
  &lt;a href="https://goodfirstissue.dev"&gt;
    &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hcGUuSCZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://goodfirstissue.dev/images/gfi-logo-dark.svg"&gt;
  &lt;/a&gt;
&lt;/p&gt;




&lt;p&gt;&lt;a href="https://goodfirstissue.dev/"&gt;Good First Issue&lt;/a&gt; is an initiaitive to curate easy pickings from popular projects, so developers who've never made a contribution to open-source can get started easily.&lt;/p&gt;

&lt;p&gt;Open-source maintainers are always looking to get more people involved, but new developers generally think it's difficult to become a contributor. We believe getting developers to fix super-easy issues removes the barrier for future contributions. This is why Good First Issue exists.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding a new project
&lt;/h2&gt;

&lt;p&gt;You're welcome to add a new project in Good First Issue, and we encourage all projects — old and new, big and small.&lt;/p&gt;

&lt;p&gt;Follow these simple steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Make sure your GitHub repository has at least one issue with the &lt;code&gt;good first issue&lt;/code&gt; label. This label is already present on all repositories by default. If not, you can follow the steps &lt;a href="https://help.github.com/en/github/managing-your-work-on-github/applying-labels-to-issues-and-pull-requests"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the repository's path in &lt;a href="//data/repositories.toml"&gt;data/repositories.toml&lt;/a&gt; here - &lt;a href="https://github.com/deepsourcelabs/good-first-issue/blob/master/data/repositories.toml"&gt;github.com/deepsourcelabs/good-first-issue&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new pull-request. Once the pull-request is merged, the changes will be live on &lt;a href="https://goodfirstissue.dev/"&gt;goodfirstissue.dev&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>showdev</category>
      <category>opensource</category>
    </item>
    <item>
      <title>DeepSource Go analyzer is now generally available</title>
      <dc:creator>Jai Pradeesh</dc:creator>
      <pubDate>Mon, 09 Dec 2019 07:14:35 +0000</pubDate>
      <link>https://dev.to/deepsource/deepsource-go-analyzer-is-now-generally-available-3afg</link>
      <guid>https://dev.to/deepsource/deepsource-go-analyzer-is-now-generally-available-3afg</guid>
      <description>&lt;p&gt;Go programming language has taken the developer ecosystem by storm. Since it's creation in 2009, the language has seen tremendous global adoption by developers looking for a lightweight as well as expressive language suited for microservices architectures. It has been touted to be on a trajectory to become the next &lt;a href="https://hackernoon.com/go-is-on-a-trajectory-to-become-the-next-enterprise-programming-language-3b75d70544e" rel="noopener noreferrer"&gt;enterprise programming language&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;DeepSource Go analyzer is now generally available and is free to use for open-source repositories.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ftf1b2n41d1mdz77af82i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ftf1b2n41d1mdz77af82i.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Issue distribution
&lt;/h2&gt;

&lt;p&gt;The analyzer detects 150+ types of issues falling into the following categories — bug risks, anti-patterns, security vulnerabilities, performance issues, documentation coverage and style violations.&lt;/p&gt;

&lt;p&gt;Here's quick overview of some sample issues from each of these categories.&lt;/p&gt;

&lt;h4&gt;
  
  
  Bug risks
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Incorrect usage of &lt;code&gt;append&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;defer&lt;/code&gt; in infinite loops which will never execute&lt;/li&gt;
&lt;li&gt;Invalid regular expressions&lt;/li&gt;
&lt;li&gt;Assignment to &lt;code&gt;nil&lt;/code&gt; map&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Security vulnerabilities
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Poor file permissions&lt;/li&gt;
&lt;li&gt;Binding to all interfaces&lt;/li&gt;
&lt;li&gt;Hard-coded credentials in source code&lt;/li&gt;
&lt;li&gt;Use of un-escaped data in HTML templates&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Performance issues
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Storing non-pointer values in &lt;code&gt;sync.Pool&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;time.Tick&lt;/code&gt; in a leaky way&lt;/li&gt;
&lt;li&gt;Optimizations when indexing maps by byte slices&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Anti-patterns
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Duplicate build constraints&lt;/li&gt;
&lt;li&gt;Trapping signals like &lt;code&gt;SIGKILL&lt;/code&gt; and &lt;code&gt;SIGSTOP&lt;/code&gt; that can't be trapped&lt;/li&gt;
&lt;li&gt;Redundant control flows&lt;/li&gt;
&lt;li&gt;Missing error checks&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Style violations
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Incorrectly formatted error string&lt;/li&gt;
&lt;li&gt;Misplaced &lt;code&gt;default&lt;/code&gt; case in switch statements&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting Started with GitHub
&lt;/h2&gt;

&lt;p&gt;Analyzing Go code with DeepSource is straightforward. Just add a &lt;code&gt;.deepsource.toml&lt;/code&gt; file to the repository root to tell DeepSource which analyzers to run. The following example configuration will run go analysis continuously on all pull requests.&lt;/p&gt;

&lt;p&gt;File: &lt;code&gt;.deepsource.toml&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="py"&gt;version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="py"&gt;test_patterns&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="s"&gt;"tests/*_test.go"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;"**/*_test.go"&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="nn"&gt;[[analyzers]]&lt;/span&gt;
&lt;span class="py"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"go"&lt;/span&gt;
&lt;span class="py"&gt;enabled&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

  &lt;span class="nn"&gt;[analyzers.meta]&lt;/span&gt;
  &lt;span class="py"&gt;import_path&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"github.com/username/repository"&lt;/span&gt;

&lt;span class="nn"&gt;[[analyzers]]&lt;/span&gt;
&lt;span class="py"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"test-coverage"&lt;/span&gt;
&lt;span class="py"&gt;enabled&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Tracking test coverage
&lt;/h2&gt;

&lt;p&gt;You can also track test coverage for your Go code. Post enabling test coverage analyzer (above step), use DeepSource CLI to report metrics from any CI systems.&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="c"&gt;# Run your tests and generate coverage report&lt;/span&gt;
go &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;-coverprofile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;coverage.out

&lt;span class="c"&gt;# Install 'deepsource CLI'&lt;/span&gt;
curl https://deepsource.io/cli | sh

&lt;span class="c"&gt;# Set DEEPSOURCE_DSN env variable from repository settings page&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;DEEPSOURCE_DSN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://sampledsn@deepsource.io

&lt;span class="c"&gt;# Report coverage artifact to 'test-coverage' analyzer&lt;/span&gt;
./bin/deepsource report &lt;span class="nt"&gt;--analyzer&lt;/span&gt; test-coverage &lt;span class="nt"&gt;--key&lt;/span&gt; go &lt;span class="nt"&gt;--value-file&lt;/span&gt; ./coverage.out
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go build.&lt;/p&gt;

</description>
      <category>showdev</category>
    </item>
    <item>
      <title>Package management in Go</title>
      <dc:creator>Jai Pradeesh</dc:creator>
      <pubDate>Wed, 11 Sep 2019 07:50:56 +0000</pubDate>
      <link>https://dev.to/deepsource/package-management-in-go-4dhj</link>
      <guid>https://dev.to/deepsource/package-management-in-go-4dhj</guid>
      <description>&lt;p&gt;Package management is one of the things Go has always missed. One of the major drawbacks of the previous (pre 1.11) &lt;code&gt;go get&lt;/code&gt; was lack of support for managing dependency versions and enabling reproducible builds. The community has developed package managers and tools like Glide, dep and &lt;a href="https://github.com/golang/go/wiki/PackageManagementTools"&gt;many others&lt;/a&gt; serving as de-facto solutions for versioning dependencies.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I use go get for production builds." — said no one ever.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Go's implementation of package management traces its origins back to Google (which has a giant monolithic repository for all their source code). Let's break down on what's wrong with 'pre - go module' package management tooling.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Versioning dependencies&lt;/li&gt;
&lt;li&gt;Vendoring dependencies&lt;/li&gt;
&lt;li&gt;The necessity of &lt;code&gt;GOPATH&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Versioning dependencies
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;go get&lt;/code&gt; by default didn't support module versioning. The idea behind the first version of go's package management was — no need for module versioning, no need for 3rd-party module repositories, you build everything from your current branch.&lt;/p&gt;

&lt;p&gt;Pre Go 1.11, adding a dependency meant cloning that dependency's source code repo in your &lt;code&gt;GOPATH&lt;/code&gt;. That was about it. There was no concept of versions. Rather, it always pointed to the current master branch at the time of cloning. Another major issue cropped up when different projects needed different versions of a dependency — which wasn't possible either.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vendoring dependencies
&lt;/h2&gt;

&lt;p&gt;Package vendoring is commonly referred to as the case where dependent packages are stored in the same place as your project. That usually means your dependencies are checked into your source management system, such as Git.&lt;/p&gt;

&lt;p&gt;Consider this case — A uses dependency B, which uses a feature of dependency C introduced in version 1.5 of C, B must be able to ensure that A's build uses C 1.5 or later. Pre Go 1.5, there was no mechanism for carrying dependency code alongside commands without rewriting import paths.&lt;/p&gt;

&lt;h2&gt;
  
  
  Necessity of &lt;code&gt;GOPATH&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;GOPATH&lt;/code&gt; exists for two main reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In Go, the &lt;code&gt;import&lt;/code&gt; declaration references a package via its fully qualified import path. &lt;code&gt;GOPATH&lt;/code&gt; exist so that from any directory inside &lt;code&gt;GOPATH/src&lt;/code&gt; the go tool can compute the absolute import path of the package in question.&lt;/li&gt;
&lt;li&gt;A location to store dependencies fetched by &lt;code&gt;go get.&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What's wrong with this?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;GOPATH&lt;/code&gt; doesn’t allow checking out the source of a project in a directory of choice like they are used to with other languages.&lt;/li&gt;
&lt;li&gt;Additionally, &lt;code&gt;GOPATH&lt;/code&gt; does not let the developer have more than one copy of a project (or its dependencies) checked out at the same time.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Introducing Go Modules
&lt;/h2&gt;

&lt;p&gt;Go 1.11 introduces preliminary support for Go modules. From Go Wiki,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A &lt;em&gt;module&lt;/em&gt; is a collection of related Go packages that are versioned together as a single unit. Modules record precise dependency requirements and create reproducible builds.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Go modules brings three important features built-in,&lt;/p&gt;

&lt;p&gt;1) &lt;code&gt;go.mod&lt;/code&gt; file similar to &lt;code&gt;package.json&lt;/code&gt; or &lt;code&gt;Pipfile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;2) A machine-generated transitive dependency description - &lt;code&gt;go.sum&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;3) No more &lt;code&gt;GOPATH&lt;/code&gt; limitation. Modules can be in any path.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;go &lt;span class="nb"&gt;help &lt;/span&gt;mod
Go mod provides access to operations on modules.

Note that support &lt;span class="k"&gt;for &lt;/span&gt;modules is built into all the go commands,
not just &lt;span class="s1"&gt;'go mod'&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; For example, day-to-day adding, removing, upgrading,
and downgrading of dependencies should be &lt;span class="k"&gt;done &lt;/span&gt;using &lt;span class="s1"&gt;'go get'&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
See &lt;span class="s1"&gt;'go help modules'&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;an overview of module functionality.

Usage:

    go mod &amp;lt;&lt;span class="nb"&gt;command&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;arguments]

The commands are:

    download    download modules to &lt;span class="nb"&gt;local &lt;/span&gt;cache
    edit        edit go.mod from tools or scripts
    graph       print module requirement graph
    init        initialize new module &lt;span class="k"&gt;in &lt;/span&gt;current directory
    tidy        add missing and remove unused modules
    vendor      make vendored copy of dependencies
    verify      verify dependencies have expected content
    why         explain why packages or modules are needed

Use &lt;span class="s2"&gt;"go help mod &amp;lt;command&amp;gt;"&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;more information about a command.

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Relevant &lt;a href="https://groups.google.com/forum/#!topic/golang-dev/a5PqQuBljF4"&gt;discussion thread&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Migrating to Go Modules
&lt;/h2&gt;

&lt;p&gt;To use Go modules, update Go to version &lt;code&gt;&amp;gt;= 1.11&lt;/code&gt;. Since &lt;code&gt;GOPATH&lt;/code&gt; is going away, one can activate module support in one of these two ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Invoke the &lt;code&gt;go&lt;/code&gt; command in a directory outside of the &lt;code&gt;GOPATH/src&lt;/code&gt; tree, with a valid &lt;code&gt;go.mod&lt;/code&gt; file in the current directory.&lt;/li&gt;
&lt;li&gt;Go modules don't work if source is under &lt;code&gt;GOPATH&lt;/code&gt;. To override this behaviour, invoke the &lt;code&gt;go&lt;/code&gt; command with &lt;code&gt;GO111MODULE=on&lt;/code&gt; environment variable set.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's start porting by following these simple steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;As &lt;code&gt;GOPATH&lt;/code&gt; isn't necessary anymore, move the module out of &lt;code&gt;GOPATH&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From the project root, create the initial module definition - &lt;code&gt;go mod init github.com/username/repository&lt;/code&gt;. The best part is, &lt;code&gt;go mod&lt;/code&gt; automatically converts dependencies from existing package managers like &lt;code&gt;dep&lt;/code&gt;, &lt;code&gt;Gopkg&lt;/code&gt;, &lt;code&gt;glide&lt;/code&gt; and &lt;a href="https://tip.golang.org/pkg/cmd/go/internal/modconv/?m=all#pkg-variables"&gt;six others&lt;/a&gt;. This will create a file called &lt;code&gt;go.mod&lt;/code&gt; with the module name and dependencies with its versions.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;go.mod
module github.com/deepsourcelabs/cli

go 1.12

require &lt;span class="o"&gt;(&lt;/span&gt;
    github.com/certifi/gocertifi v0.0.0-20190410005359-59a85de7f35e
    github.com/getsentry/raven-go v0.2.0
    github.com/pkg/errors v0.0.0-20190227000051-27936f6d90f9
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Run &lt;code&gt;go build&lt;/code&gt; to create a &lt;code&gt;go.sum&lt;/code&gt; file which contains the expected cryptographic checksums of the content of specific module versions. This is to ensure that future downloads of these modules retrieve the same bits as the first download. Note that go.sum is not a lock file.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;go.sum
github.com/certifi/gocertifi v0.0.0-20190410005359-59a85de7f35e h1:9574pc8MX6rF/QyO14SPHhM5KKIOo9fkb/1ifuYMTKU&lt;span class="o"&gt;=&lt;/span&gt;
github.com/certifi/gocertifi v0.0.0-20190410005359-59a85de7f35e/go.mod h1:GJKEexRPVJrBSOjoqN5VNOIKJ5Q3RViH6eu3puDRwx4&lt;span class="o"&gt;=&lt;/span&gt;
github.com/getsentry/raven-go v0.2.0 h1:no+xWJRb5ZI7eE8TWgIq1jLulQiIoLG0IfYxv5JYMGs&lt;span class="o"&gt;=&lt;/span&gt;
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ&lt;span class="o"&gt;=&lt;/span&gt;
github.com/pkg/errors v0.0.0-20190227000051-27936f6d90f9 h1:dIsTcVF0w9viTLHXUEkDI7cXITMe+M/MRRM2MwisVow&lt;span class="o"&gt;=&lt;/span&gt;
github.com/pkg/errors v0.0.0-20190227000051-27936f6d90f9/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0&lt;span class="o"&gt;=&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note on versioning: To maintain backward compatibility, if the module is version v2 or higher, the major version of the module &lt;em&gt;must&lt;/em&gt; be included as a &lt;code&gt;/vN&lt;/code&gt; at the end of the module paths used in &lt;code&gt;go.mod&lt;/code&gt;files (e.g., &lt;code&gt;module github.com/username/repository/v2&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Everyday commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  List dependencies
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;go list -m all&lt;/code&gt; lists the current module and all its dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;go list &lt;span class="nt"&gt;-m&lt;/span&gt; all
github.com/deepsourcelabs/cli
github.com/certifi/gocertifi v0.0.0-20190410005359-59a85de7f35e
github.com/getsentry/raven-go v0.2.0
github.com/pkg/errors v0.0.0-20190227000051-27936f6d90f9
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In the &lt;code&gt;go list&lt;/code&gt; output, the current module, also known as the &lt;em&gt;main module&lt;/em&gt;, is always the first line, followed by dependencies sorted by module path.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  List available versions of a package
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;go list -m -versions github.com/username/repository&lt;/code&gt; lists available versions of a package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;go list &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="nt"&gt;-versions&lt;/span&gt; github.com/getsentry/raven-go
github.com/getsentry/raven-go v0.1.0 v0.1.1 v0.1.2 v0.2.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Add a dependency
&lt;/h3&gt;

&lt;p&gt;Adding a dependency is implicit. After importing a dependency in code, running &lt;code&gt;go build&lt;/code&gt; or &lt;code&gt;go test&lt;/code&gt; command gets the latest version of the module and adds it to &lt;code&gt;go.mod&lt;/code&gt; file. If you would like to add a dependency explicitly, run&lt;code&gt;go get github.com/username/repository&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Upgrade/downgrade a dependency
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;go get github.com/username/repository@vx.x.x&lt;/code&gt; downloads and sets the specific version of the dependency and updates &lt;code&gt;go.mod&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;go get github.com/getsentry/raven-go@v0.1.2
go: finding github.com/getsentry/raven-go v0.1.2
go: downloading github.com/getsentry/raven-go v0.1.2
go: extracting github.com/getsentry/raven-go v0.1.2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;go.mod 
module github.com/deepsourcelabs/marvin-go

go 1.12

require &lt;span class="o"&gt;(&lt;/span&gt;
    github.com/certifi/gocertifi v0.0.0-20190410005359-59a85de7f35e
    github.com/getsentry/raven-go v0.1.2
    github.com/pkg/errors v0.0.0-20190227000051-27936f6d90f9
&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;go.sum
github.com/certifi/gocertifi v0.0.0-20190410005359-59a85de7f35e h1:9574pc8MX6rF/QyO14SPHhM5KKIOo9fkb/1ifuYMTKU&lt;span class="o"&gt;=&lt;/span&gt;
github.com/certifi/gocertifi v0.0.0-20190410005359-59a85de7f35e/go.mod h1:GJKEexRPVJrBSOjoqN5VNOIKJ5Q3RViH6eu3puDRwx4&lt;span class="o"&gt;=&lt;/span&gt;
github.com/getsentry/raven-go v0.1.2 h1:4V0z512S5mZXiBvmW2RbuZBSIY1sEdMNsPjpx2zwtSE&lt;span class="o"&gt;=&lt;/span&gt;
github.com/getsentry/raven-go v0.1.2/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ&lt;span class="o"&gt;=&lt;/span&gt;
github.com/getsentry/raven-go v0.2.0 h1:no+xWJRb5ZI7eE8TWgIq1jLulQiIoLG0IfYxv5JYMGs&lt;span class="o"&gt;=&lt;/span&gt;
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ&lt;span class="o"&gt;=&lt;/span&gt;
github.com/pkg/errors v0.0.0-20190227000051-27936f6d90f9 h1:dIsTcVF0w9viTLHXUEkDI7cXITMe+M/MRRM2MwisVow&lt;span class="o"&gt;=&lt;/span&gt;
github.com/pkg/errors v0.0.0-20190227000051-27936f6d90f9/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0&lt;span class="o"&gt;=&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Vendoring dependencies
&lt;/h3&gt;

&lt;p&gt;When using modules, the go command completely ignores vendor directories. For backward compatibility with older versions of Go, or to ensure that all files used for a build are stored together in a single file tree, run&lt;code&gt;go mod vendor&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This creates a directory named &lt;code&gt;vendor&lt;/code&gt; in the root directory of the main module and stores all the packages from dependency modules there.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: To build using the main module's top-level vendor directory, run 'go build -mod=vendor'.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Remove unused dependencies
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;go mod tidy&lt;/code&gt; trims unused dependencies and updates &lt;code&gt;go.mod&lt;/code&gt; file.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQs
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Is &lt;code&gt;GOPATH&lt;/code&gt; not needed anymore?
&lt;/h4&gt;

&lt;p&gt;No. Farewell &lt;code&gt;GOPATH&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Which version is pulled by default?
&lt;/h4&gt;

&lt;p&gt;The go.mod file and the go command more generally use semantic versions as the standard form for describing module versions, so that versions can be compared to determine which should be considered earlier or later than another. A module version like &lt;code&gt;v1.2.3&lt;/code&gt; is introduced by tagging a revision in the underlying source repository. Untagged revisions can be referred to using a "pseudo-version" like &lt;code&gt;v0.0.0-yyyymmddhhmmss-abcdefabcdef&lt;/code&gt;, where the time is the commit time in UTC and the final suffix is the prefix of the commit hash.&lt;/p&gt;

&lt;h4&gt;
  
  
  Should &lt;code&gt;go.sum&lt;/code&gt; be checked into version control?
&lt;/h4&gt;

&lt;p&gt;Yes.&lt;/p&gt;

</description>
      <category>go</category>
    </item>
    <item>
      <title>Importance of software documentation</title>
      <dc:creator>Jai Pradeesh</dc:creator>
      <pubDate>Thu, 18 Jul 2019 02:32:42 +0000</pubDate>
      <link>https://dev.to/jaipradeesh/importance-of-software-documentation-8mi</link>
      <guid>https://dev.to/jaipradeesh/importance-of-software-documentation-8mi</guid>
      <description>&lt;p&gt;Software evolves, and changes to software are inevitable. In general, any work done to change the software after it is in operation is considered to be maintenance. Maintenance consumes over 70% of the total life-cycle cost of a software project &lt;sup&gt;1&lt;/sup&gt;. If you think about it for a while, you would realize how critical maintenance work is to keep the software alive. Interestingly, the act of reading code is the most time-consuming component of all maintenance activities performed by software developers.&lt;/p&gt;

&lt;p&gt;Since readability poses such importance on maintenance of software, let’s understand how do we define it. In natural languages, readability is defined as how easy a text is to understand. In literature, readability is objectively judged by metrics like average syllables per word, average sentence length, etc. Raising the readability level of a text from mediocre to good can make the difference between success and failure of its communication goals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Programs must be written for people to read and only incidentally for machines to execute.&lt;/strong&gt; Thus spoke the authors of the authoritative book on software development patterns, &lt;a href="https://mitpress.mit.edu/sites/default/files/sicp/index.html"&gt;SICP&lt;/a&gt;. So how do we make sure the communication goals of source code is delivered to the developers?&lt;/p&gt;

&lt;h3&gt;
  
  
  Source code is not documentation
&lt;/h3&gt;

&lt;p&gt;You would often see software developers treat source code as the primary or at times, the only documentation. For this to manifest in practice, the code has to be sufficiently detailed and precise. But source code in its original form is not readable as plain text. As noted earlier, readability plays a huge part in making software accessible and maintainable. Any documentation that is written must be easy to understand not just by the immediate team members but also by future stakeholders. Some examples of why this is important are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When interfacing with external modules, the consumer should understand the exposed interfaces by the existing module.&lt;/li&gt;
&lt;li&gt;To extend a module, existing models and concepts need to be understood in detail.&lt;/li&gt;
&lt;li&gt;To identify a bug and patch a fix faster, detailed documentation can be critical.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Of course, for the documentation to be effective, it must be maintained along with the code itself. When refactoring code it has to be made sure that the documentation reflects the change as well. All seasoned engineering teams put the impetus on tracking changes in documentation when the code is updated.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to write good documentation?
&lt;/h3&gt;

&lt;p&gt;Three golden rules when writing documentation are asking yourself these questions while writing comments:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What does this piece of code do?&lt;/li&gt;
&lt;li&gt;How does it do it?&lt;/li&gt;
&lt;li&gt;How does someone use it somewhere else?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When you treat comments as part of source code, make sure it’s reviewed along in the merge process. If there is one takeaway from this post, it is treating documentation equally as source code as part of review process.&lt;/p&gt;

&lt;p&gt;Embedded documentation helps the programmer to stay within the context and understand thoroughly. It also exhibits a significant level of correlation with other conventional metrics such as software quality, code churn, etc. A code base is owned primarily by a team, not an individual. It’s important that developers put in the effort to make sure that the code they write is clear and readable. Some teams may prefer to skip code documentation in order to save time, money and effort. Keep in mind though that this might result in even more significant expenses once the product is transferred to another team or when updates are required down the line.&lt;/p&gt;

&lt;h4&gt;
  
  
  References
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.cs.umd.edu/projects/SoftEng/ESEG/papers/82.78.pdf"&gt;Software Defect Reduction Top 10 List&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://martinfowler.com/bliki/CodeAsDocumentation.html"&gt;CodeAsDocumentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pdfs.semanticscholar.org/ba06/f1ecc9014bb832d94eed1ceeeccedf65c6a9.pdf"&gt;A Survey of Improving Computer Program Readability to Aid Modification&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>codequality</category>
      <category>documentation</category>
    </item>
  </channel>
</rss>
