<?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: Kassim Damilola A</title>
    <description>The latest articles on DEV Community by Kassim Damilola A (@kdnotes).</description>
    <link>https://dev.to/kdnotes</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%2F161967%2F2adefe2e-2c23-4778-88e7-095dffba2233.jpg</url>
      <title>DEV Community: Kassim Damilola A</title>
      <link>https://dev.to/kdnotes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kdnotes"/>
    <language>en</language>
    <item>
      <title>Command-Line Flags with Go-Lang</title>
      <dc:creator>Kassim Damilola A</dc:creator>
      <pubDate>Sun, 03 Nov 2019 22:11:54 +0000</pubDate>
      <link>https://dev.to/kdnotes/command-line-flags-with-go-lang-5fag</link>
      <guid>https://dev.to/kdnotes/command-line-flags-with-go-lang-5fag</guid>
      <description>&lt;p&gt;Command-line flags are a common way to specify options for command-line exercutables or programs.&lt;/p&gt;

&lt;p&gt;Go provides a flag package supporting basic command-line flag parsing.&lt;/p&gt;

&lt;p&gt;Flags are defined using flag.String(), Bool(), Int(), etc. Depending on the intended datatype.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;First argument — Flag name
Second argument — Default value
Third argument — help message for flag nameinstances := flag.Int(“instances”, 5, “number of deployed instance”)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After all flags are defined, call&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


to parse the command line into the defined flags.

Command line flag syntax

The following forms are permitted:



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

&lt;p&gt;-flag&lt;br&gt;
-flag=x&lt;br&gt;
-flag x // non-boolean flags only&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/tg31fio6y47bkuaft2vs.png)



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

&lt;p&gt;$ go build flags.go&lt;/p&gt;

&lt;p&gt;./flag -h&lt;br&gt;
  -instances int&lt;br&gt;
        number of deployed instances (default 5)&lt;/p&gt;

&lt;p&gt;$ ./flags -instances 7 &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

</description>
      <category>go</category>
      <category>flags</category>
      <category>cli</category>
    </item>
    <item>
      <title>Passing CLI arguments to excutables with 'go run'</title>
      <dc:creator>Kassim Damilola A</dc:creator>
      <pubDate>Sat, 02 Nov 2019 23:43:51 +0000</pubDate>
      <link>https://dev.to/kdnotes/passing-cli-arguments-to-excutables-with-go-run-1k5o</link>
      <guid>https://dev.to/kdnotes/passing-cli-arguments-to-excutables-with-go-run-1k5o</guid>
      <description>&lt;p&gt;os.Args provides access to raw command-line arguments.&lt;/p&gt;

&lt;p&gt;Note that the first value in this slice is the path to the program, and os.Args[1:] holds the arguments to the program.&lt;/p&gt;

&lt;p&gt;You can get individual args with normal indexing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HCYPki_P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rt0900lfuw2j3u8dsse9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HCYPki_P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rt0900lfuw2j3u8dsse9.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To experiment with command-line arguments run 'go run cli.go parameter-1 parameter 2'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ parameter-1 parameter 2]
 parameter-1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>go</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
