<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Golang on CyberSpy</title>
    <link>https://cyberspy.io/tags/golang/</link>
    <description>Recent content in Golang on CyberSpy</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Tue, 10 Dec 2019 09:55:44 -0500</lastBuildDate>
    <atom:link href="https://cyberspy.io/tags/golang/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Getting func(y) with Channels</title>
      <link>https://cyberspy.io/code/channelfuncs/</link>
      <pubDate>Tue, 10 Dec 2019 09:55:44 -0500</pubDate>
      <guid>https://cyberspy.io/code/channelfuncs/</guid>
      <description>&lt;h2 id=&#34;heres-a-little-golang-puzzle&#34;&gt;Here&amp;rsquo;s a little golang puzzle&lt;/h2&gt;&#xA;&lt;p&gt;Take a look at the function below that computes a mystery value for the function $f(x)$. Any idea what the function is? Take a close look at the first line where we create a channel. Notice that the channel isn&amp;rsquo;t some boring &lt;code&gt;int&lt;/code&gt; or &lt;code&gt;string&lt;/code&gt; channel. No, this is a channel of type &lt;code&gt;func(int, chan int, chan bool)&lt;/code&gt;. Wait what??? That&amp;rsquo;s right, this channel takes a function that takes an integer and two channels as function parameters. We define such a function, &lt;code&gt;x&lt;/code&gt;, right aftewards.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Pothos - A New Take on Data-Flow Frameworks</title>
      <link>https://cyberspy.io/articles/pothossdr/</link>
      <pubDate>Wed, 17 Jan 2018 11:13:11 -0500</pubDate>
      <guid>https://cyberspy.io/articles/pothossdr/</guid>
      <description>&lt;h3 id=&#34;data-flows-like-a-river&#34;&gt;Data-Flows&amp;hellip; &lt;em&gt;like a river&lt;/em&gt;&lt;/h3&gt;&#xA;&lt;p&gt;In today&amp;rsquo;s post, I thought I&amp;rsquo;d take a look at and discuss the &lt;a href=&#34;https://github.com/pothosware/PothosCore/wiki&#34;&gt;Pothos&lt;/a&gt; toolkit, a work-flow tool that improves upon the design principles of &lt;a href=&#34;https://www.gnuradio.org&#34;&gt;gnuradio&lt;/a&gt; and enables real-time data-flow processes for real-time applications.&lt;/p&gt;&#xA;&lt;p&gt;Using a MacBook Pro, an &lt;a href=&#34;https://www.ettus.com/product/details/UN210-KIT&#34;&gt;ettus N210&lt;/a&gt; SDR, and an FM-antenna, I&amp;rsquo;ll show how easy it is to build an FM Receiver to listen to your favorite radio stations on your laptop. While it&amp;rsquo;s an expensive way to tune in to your local DJ, it&amp;rsquo;s a great demonstration of how to use this great kit (written by &lt;a href=&#34;http://www.joshknows.com&#34;&gt;Josh Blum&lt;/a&gt;).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Crypto 101: A Brief Tour of Practical Crypto in Golang</title>
      <link>https://cyberspy.io/articles/crypto101/</link>
      <pubDate>Thu, 14 Dec 2017 10:38:41 -0500</pubDate>
      <guid>https://cyberspy.io/articles/crypto101/</guid>
      <description>&lt;h2 id=&#34;crypto-101&#34;&gt;Crypto 101:&lt;/h2&gt;&#xA;&lt;p&gt;Golang offers a rich collection of packages supporting cryptographic operations. From a beginner&amp;rsquo;s perspective, maybe too many offerings! I offer up an overview of what&amp;rsquo;s available and an introduction to some practical uses of cryptography in Golang. Implementation details are always critical when discussing crypto. We&amp;rsquo;ll discuss some general implications of making poor choices and how such choices can completely undermine any uses of these tools.&lt;/p&gt;&#xA;&lt;h3 id=&#34;what-in-the-box&#34;&gt;What&amp;rsquo; in the box?&lt;/h3&gt;&#xA;&lt;p&gt;The top-level &lt;code&gt;crypto&lt;/code&gt; package is comprised of a little over a dozen sub-packages that offer:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Channel Your Inner Gopher</title>
      <link>https://cyberspy.io/articles/channelyourgopher/</link>
      <pubDate>Wed, 13 Dec 2017 11:44:07 -0500</pubDate>
      <guid>https://cyberspy.io/articles/channelyourgopher/</guid>
      <description>&lt;h3 id=&#34;channeling-your-inner-gopher---literally-reflecting-upon-channels&#34;&gt;Channeling your Inner Gopher - (Literally) Reflecting upon Channels&lt;/h3&gt;&#xA;&lt;p&gt;Many gophers are likely familiar with the communication paradigm, &lt;em&gt;channels&lt;/em&gt;. An elegant solution to communicate (uni or bidirectionally) typed information among go-routines. In it&amp;rsquo;s simplest form, we declare as type-valued channel variable, &lt;strong&gt;make&lt;/strong&gt; it, and then send and receive data through it. Easy enough!&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-golang&#34; data-lang=&#34;golang&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;package&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;main&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; (&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;fmt&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;func&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;main&lt;/span&gt;() {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;simpleChan&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;chan&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;int&lt;/span&gt; = make(&lt;span style=&#34;color:#66d9ef&#34;&gt;chan&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;int&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;go&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;func&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;c&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;chan&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;int&lt;/span&gt;) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#75715e&#34;&gt;// send important data to the channel&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                &lt;span style=&#34;color:#a6e22e&#34;&gt;c&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;-&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;42&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                close(&lt;span style=&#34;color:#a6e22e&#34;&gt;c&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }(&lt;span style=&#34;color:#a6e22e&#34;&gt;simpleChan&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#75715e&#34;&gt;// receive data&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#a6e22e&#34;&gt;num&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;-&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;simpleChan&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#a6e22e&#34;&gt;fmt&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Printf&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;got %d\n&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;num&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In our trivial example above, we create an &lt;code&gt;chan int&lt;/code&gt; typed-channel and initialize it using &lt;code&gt;make&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Shoutout1</title>
      <link>https://cyberspy.io/quote/shoutout1/</link>
      <pubDate>Sat, 02 Dec 2017 10:36:00 -0500</pubDate>
      <guid>https://cyberspy.io/quote/shoutout1/</guid>
      <description>&lt;blockquote&gt;&#xA;&lt;p&gt;Wanna &lt;strong&gt;learn&lt;/strong&gt; you some Go? &lt;em&gt;&lt;strong&gt;&lt;a href=&#34;https://golangbot.com/learn-golang-series/&#34;&gt;Tutor&lt;/a&gt;&lt;/strong&gt;&lt;/em&gt; up over here!&lt;/p&gt;&#xA;&lt;/blockquote&gt;</description>
    </item>
    <item>
      <title>Go Get Interfaced: Enums in Golang</title>
      <link>https://cyberspy.io/code/gogetinterfaces/</link>
      <pubDate>Sat, 02 Dec 2017 09:38:42 -0500</pubDate>
      <guid>https://cyberspy.io/code/gogetinterfaces/</guid>
      <description>&lt;h3 id=&#34;golang-interfaces-and-enums&#34;&gt;Golang, Interfaces, and Enums&lt;/h3&gt;&#xA;&lt;p&gt;So here&amp;rsquo;s a nice golang idiom that I ran across years ago that I found generally useful. Golang, unlike languages like &lt;strong&gt;c&lt;/strong&gt; doesn&amp;rsquo;t natively support enumerations. Instead, constants typically are used when creating a list of enumerations. But, go is a strongly-typed language, so we can do better than simply using constants - we can &lt;em&gt;type&lt;/em&gt; our enumeration with the use of a &lt;code&gt;type&lt;/code&gt; declaration.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-golang&#34; data-lang=&#34;golang&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;type&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;DogState&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;uint&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;By defining a type for our enumeration, we can consistently pass and return typed-values among our functions operating on our enumeration. Okay, that&amp;rsquo;s all well and good, but what happens when we want to go between &lt;code&gt;uint&lt;/code&gt; values and &lt;code&gt;string&lt;/code&gt; representations of those values; a commonly used paradigm when working with enumerations. One approach would have us write mapping functions that might &lt;code&gt;switch&lt;/code&gt; among the values to return a &lt;code&gt;string&lt;/code&gt;. Or, when going from a &lt;code&gt;string&lt;/code&gt; name of an enumeration to the &lt;code&gt;uint&lt;/code&gt; value, we might use a &lt;code&gt;map[string]&lt;/code&gt;. That&amp;rsquo;s a doable implementation, but there&amp;rsquo;s an easier, and more idiomatic way.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Gogo</title>
      <link>https://cyberspy.io/code/gogo/</link>
      <pubDate>Wed, 29 Nov 2017 20:57:33 -0500</pubDate>
      <guid>https://cyberspy.io/code/gogo/</guid>
      <description>&lt;h3 id=&#34;here-we-gogo&#34;&gt;Here we &lt;em&gt;gogo!&lt;/em&gt;&lt;/h3&gt;&#xA;&lt;p&gt;Years ago, I wrote an interesting article that I thought might be worth re-posting (and revising) here on my blog. For a while&#xA;I got into programming in &lt;a href=&#34;https://golang.org&#34;&gt;golang&lt;/a&gt; and in the early going (pun-alert!), there were a lot of idioms that were not well understood by a &lt;em&gt;noob&lt;/em&gt;. One of those paradigms was &lt;em&gt;channels, go-routines, and signals&lt;/em&gt; used simultaneously. Taken separately, they are more easily understood. But when taken together, there can be some confusion. In this article, I address how to properly establish a signal-handler and a channel to terminate go-routines when the user interrupts the program with a signal such as &lt;code&gt;ctrl-c&lt;/code&gt; or &lt;code&gt;kill(1)&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
