<?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>Forem: Jorge Araya</title>
    <description>The latest articles on Forem by Jorge Araya (@shackra).</description>
    <link>https://forem.com/shackra</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%2F46241%2Fe317aefe-729f-454b-9edb-96eedc9603bb.jpg</url>
      <title>Forem: Jorge Araya</title>
      <link>https://forem.com/shackra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shackra"/>
    <language>en</language>
    <item>
      <title>Tell runtime/cgo to not thread warnings as errors</title>
      <dc:creator>Jorge Araya</dc:creator>
      <pubDate>Sun, 28 Jan 2024 05:13:22 +0000</pubDate>
      <link>https://forem.com/shackra/tell-runtimecgo-to-not-thread-warnings-as-errors-43el</link>
      <guid>https://forem.com/shackra/tell-runtimecgo-to-not-thread-warnings-as-errors-43el</guid>
      <description>&lt;p&gt;Occasionally, you want to debug (with delve) your project, but when you attempt to do so, you are greeted with the following error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^~~~~~~
cc1: all warnings being treated as errors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To resolve this, just export &lt;code&gt;CGO_CFLAGS&lt;/code&gt; with the value &lt;code&gt;"-O2 -g -Wno-error"&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>go</category>
      <category>cgo</category>
      <category>emacs</category>
      <category>delve</category>
    </item>
    <item>
      <title>Slice of cake</title>
      <dc:creator>Jorge Araya</dc:creator>
      <pubDate>Fri, 18 Nov 2022 00:02:00 +0000</pubDate>
      <link>https://forem.com/shackra/slice-of-cake-4jd0</link>
      <guid>https://forem.com/shackra/slice-of-cake-4jd0</guid>
      <description>&lt;p&gt;Is there a difference between slices and arrays? Well, if there is any, it is a difference of relations. &lt;code&gt;slice&lt;/code&gt; depends on &lt;code&gt;array&lt;/code&gt;, when you declare a slice in Go you get an underlying array associated with your slice, if you have several slices of the same type they may even share storage with the underlying array.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you create a slice?
&lt;/h2&gt;

&lt;p&gt;You can use the same facilities for declaring arrays in Go, with the optional argument for "capacity" provided:&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="nb"&gt;make&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="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the same as creating an array and slicing it:&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="nb"&gt;new&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="m"&gt;100&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="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  read more
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://go.dev/ref/spec#Slice_types" rel="noopener noreferrer"&gt;https://go.dev/ref/spec#Slice_types&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>slice</category>
      <category>array</category>
    </item>
  </channel>
</rss>
