<?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: Pavel Belokon</title>
    <description>The latest articles on DEV Community by Pavel Belokon (@pbelokon).</description>
    <link>https://dev.to/pbelokon</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%2F949414%2Fb8dc5bfe-74ca-4dbe-8736-59ae9c09fcac.jpg</url>
      <title>DEV Community: Pavel Belokon</title>
      <link>https://dev.to/pbelokon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pbelokon"/>
    <language>en</language>
    <item>
      <title>Embedding Structs in Go</title>
      <dc:creator>Pavel Belokon</dc:creator>
      <pubDate>Thu, 05 Sep 2024 00:24:51 +0000</pubDate>
      <link>https://dev.to/pbelokon/embedding-structs-in-go-2m2o</link>
      <guid>https://dev.to/pbelokon/embedding-structs-in-go-2m2o</guid>
      <description>&lt;p&gt;Since Go lacks traditional inheritance and objects, it still adheres closely to object-oriented principles. Instead of using objects, we use structs, and instead of inheritance, we use embedding.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Milk&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;MilkType&lt;/span&gt;  &lt;span class="c"&gt;// Type of milk&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Cheese&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Milk&lt;/span&gt;
    &lt;span class="n"&gt;Time&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Time&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;cheese&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Cheese&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"10 years"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;cheese&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MilkType&lt;/span&gt; &lt;span class="c"&gt;// Accesses the type of milk&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, you can see how we can access the Milk struct from Cheese. This approach is simple to write and easy to understand.&lt;/p&gt;

&lt;p&gt;So far I really enjoy Go 😀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Cool ways to write functions in Go</title>
      <dc:creator>Pavel Belokon</dc:creator>
      <pubDate>Wed, 28 Aug 2024 03:53:34 +0000</pubDate>
      <link>https://dev.to/pbelokon/cool-ways-to-write-functions-in-go-2fjj</link>
      <guid>https://dev.to/pbelokon/cool-ways-to-write-functions-in-go-2fjj</guid>
      <description>&lt;p&gt;Today, I learned something handy about Go's functions. You can actually return multiple values, unlike in JavaScript, where I would typically return an object containing the state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;  &lt;span class="c"&gt;// Example&lt;/span&gt;
  &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Hurray!"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also name the return values, which makes them local variables within the function and allows for an "empty return".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;  &lt;span class="c"&gt;// Example&lt;/span&gt;
  &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
     &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hurray!"&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although I don't find using an empty return to be the best way to write functions, it’s still pretty cool.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My first day with GO</title>
      <dc:creator>Pavel Belokon</dc:creator>
      <pubDate>Mon, 26 Aug 2024 01:57:31 +0000</pubDate>
      <link>https://dev.to/pbelokon/my-first-day-with-go-1m35</link>
      <guid>https://dev.to/pbelokon/my-first-day-with-go-1m35</guid>
      <description>&lt;p&gt;Today, I embarked on a journey to find a versatile programming language that would broaden my perspective on web development.&lt;/p&gt;

&lt;p&gt;After spending a lot of time with JavaScript, I felt a bit burned out and wanted to try something new but still related to the web.&lt;/p&gt;

&lt;p&gt;One of the things I found really interesting is how Go handles private and public visibility. Instead of using keywords, it's all about how a variable or function is named, uppercase for public and lowercase for private. I find this approach improves readability because you can immediately tell whether something is private or public without needing to check its definition.&lt;/p&gt;

&lt;p&gt;That's all for now. I just wanted to kick off my journey with Go by sharing these first impressions in my blog.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
