<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>emre şahin's digital garden 🍃 - Golang</title>
    <link>https://emresahin.net/categories/golang/</link>
    <description>Posts in the Golang category</description>
    <language>en</language>
    <managingEditor>contact@emresahin.net (Emre Şahin)</managingEditor>
    <lastBuildDate>Tue, 15 Sep 2026 19:46:32 +0000</lastBuildDate>
    <atom:link href="https://emresahin.net/categories/golang/rss.xml" rel="self" type="application/rss+xml"/>
    <item>
      <title>TIL 10: Structs in Go</title>
      <published>2021-01-10T18:44:55+00:00</published>
      <updated>2021-01-10T18:44:55+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Sun, 10 Jan 2021 18:44:55 +0000</pubDate>
      <link>https://emresahin.net/til-10/</link>
      <guid isPermaLink="true">https://emresahin.net/til-10/</guid>
      <description>Structs in Go In Go, it is possible to embed structs within other structs: type person struct { first string last string age int } type employee struct { person employee_id int salary int } We can instantiate the employee type as follows: e := employee{ person: person{ first: "Ali", last: "Yeşil"...</description>
      <category>Golang</category>
      <category>struct</category>
      <category>anonymous struct</category>
      <category>embedded struct</category>
      <category>Go</category>
      <category>programming</category>
      <content:encoded><![CDATA[<h2 id="structs-in-go">Structs in Go</h2>
<p>In Go, it is possible to embed structs within other structs:</p>
<pre><code class="language-go">type person struct {
    first string
    last string
    age   int
}

type employee struct {
    person
    employee_id int
    salary      int
}
</code></pre>
<p>We can instantiate the <code>employee</code> type as follows:</p>
<pre><code class="language-go">e := employee{
    person: person{
        first: "Ali",
        last:  "Yeşil",
        age:   33,
    },
    employee_id: 001,
    salary:      4500,
}
</code></pre>
<p>We can then access the fields of the embedded struct as if they were fields of the outer struct:</p>
<pre><code class="language-go">// e.first is a shorthand for e.person.first
fmt.Println(e.first) 
</code></pre>
<p>One can also use anonymous structs without explicitly defining a type:</p>
<pre><code class="language-go">z := struct {
    a string
    b int
}{
    a: "aaa",
    b: 123,
}
</code></pre>
<p>If these won’t be reused elsewhere, using anonymous structs can keep the code clean.</p>]]></content:encoded>
    </item>
    <item>
      <title>TIL: Password Hashing with Bcrypt in Go</title>
      <published>2020-12-29T20:55:06+00:00</published>
      <updated>2020-12-29T20:55:06+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Tue, 29 Dec 2020 20:55:06 +0000</pubDate>
      <link>https://emresahin.net/til-9/</link>
      <guid isPermaLink="true">https://emresahin.net/til-9/</guid>
      <description>You can use the bcrypt package for hashing passwords in Go. It also includes a cost parameter to increase the difficulty of the hashing algorithm, making it more resistant to brute-force attacks.</description>
      <category>Golang</category>
      <category>Security</category>
      <category>Encryption</category>
      <category>Hashing</category>
      <category>Passwords</category>
      <category>Bcrypt</category>
      <content:encoded><![CDATA[<p>You can use the <code>bcrypt</code> package for hashing passwords in Go. It also includes a <em>cost</em> parameter to increase the difficulty of the hashing algorithm, making it more resistant to brute-force attacks.</p>]]></content:encoded>
    </item>
  </channel>
</rss>
