<?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: Frank Li</title>
    <description>The latest articles on DEV Community by Frank Li (@ilknarf).</description>
    <link>https://dev.to/ilknarf</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%2F323087%2F1c285e42-6f50-4139-8dc7-44e679bc9ade.png</url>
      <title>DEV Community: Frank Li</title>
      <link>https://dev.to/ilknarf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ilknarf"/>
    <language>en</language>
    <item>
      <title>A few Golang notes</title>
      <dc:creator>Frank Li</dc:creator>
      <pubDate>Fri, 24 Jan 2020 04:21:14 +0000</pubDate>
      <link>https://dev.to/ilknarf/a-few-golang-notes-pjn</link>
      <guid>https://dev.to/ilknarf/a-few-golang-notes-pjn</guid>
      <description>&lt;p&gt;I've taken a liking for Golang's no-frills and elegant approach to programming. Compared to C, Golang takes care of a lot of the intricacies and annoyances of pointers and manual memory allocation while still retaining high efficiency. &lt;/p&gt;

&lt;p&gt;Another attribute of Golang that contributes to its appeal is the presence of built-in, lightweight concurrency with goroutines and channels.&lt;/p&gt;

&lt;p&gt;However, after using Golang for a while I've discovered (or rediscovered) some interesting notes:&lt;/p&gt;

&lt;h3&gt;
  
  
  Golang doesn't require explicit dereferencing to access struct attributes
&lt;/h3&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type p struct {
    u string
}

val := p{"hello"}
point := &amp;amp;p{"world"}

fmt.Println(val.u)
fmt.Println(point.u) //no dereferencing required
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Unlike C, Golang's compiler is smart enough to access the attributes of a pointer without the need for explicit dereferencing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Golang has no generic type
&lt;/h3&gt;

&lt;p&gt;Unlike many popular languages, Golang doesn't have a generic type. Instead, Go programmers use an empty interface&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func(interface{}){
    //code here
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;to write reusable or type-agnostic code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Golang's proprietary gobs are based on Google's own protocol buffers
&lt;/h3&gt;

&lt;p&gt;Interestingly, Go uses its own gob encoding as its standard encoding format (although standard JSON, XML, and YAML encoding libraries are including and just as usable. With the popularity of some of the other formats (including Google's own protocol buffers), why would they do this?&lt;/p&gt;

&lt;p&gt;The reason given &lt;a href="https://blog.golang.org/gobs-of-data"&gt;in a Go Blog post&lt;/a&gt; is that gobs are self-describing binary encodings that, while Go-specific, provide efficient data transmission over networks.&lt;/p&gt;

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