<?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: vincent muthabuku</title>
    <description>The latest articles on Forem by vincent muthabuku (@vmuthabuku).</description>
    <link>https://forem.com/vmuthabuku</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%2F134865%2F63eae9f6-0fc7-4e6f-8332-d59f5b5c7973.jpeg</url>
      <title>Forem: vincent muthabuku</title>
      <link>https://forem.com/vmuthabuku</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/vmuthabuku"/>
    <language>en</language>
    <item>
      <title>Pointers in Go</title>
      <dc:creator>vincent muthabuku</dc:creator>
      <pubDate>Mon, 15 Jun 2020 14:29:36 +0000</pubDate>
      <link>https://forem.com/vmuthabuku/pointers-in-go-53kj</link>
      <guid>https://forem.com/vmuthabuku/pointers-in-go-53kj</guid>
      <description>&lt;p&gt;Pointers in golang gave me a hard time understanding them, for me that has been the biggest challenge when it comes to learning golang, so maybe I can give a brief walkthrough of what I used to help me understan pointers in Go.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;Pointer&lt;/strong&gt; is a variable which is used to store the memory address of another variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operators&lt;/strong&gt;&lt;br&gt;
Pointers comprise of two operators &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;&amp;amp;&lt;/code&gt;. The &lt;code&gt;*&lt;/code&gt; is used to &lt;em&gt;dereference&lt;/em&gt; pointer variables, it is also used to represent/show that a variable is a pointer by putting it before the type of variable stored.&lt;br&gt;
eg &lt;code&gt;var length *int = 2&lt;/code&gt; .&lt;br&gt;
The &lt;code&gt;&amp;amp;&lt;/code&gt; is used to access the address of the variable and not the value. It is added before the variable.&lt;br&gt;
Here is a simple example on how to declare, dereference,  get a variable's address and update a variable&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
// declare length of variable&lt;br&gt;
var length int  =  12&lt;br&gt;
// declare a pointer on the width type and get it's address&lt;br&gt;
var width *int  =  &amp;amp;length&lt;br&gt;
// log length which is 12&lt;br&gt;
fmt.Println("creature =", length)&lt;br&gt;
// log the address&lt;br&gt;
fmt.Println("address =", width)&lt;br&gt;
// dereference the width and log it&lt;br&gt;
// you should get 12&lt;br&gt;
fmt.Println("*pointer dereferenced", *width)&lt;br&gt;
// change pointer value&lt;br&gt;
*width =  13&lt;br&gt;
fmt.Println("*pointer dereferenced", *width)&lt;br&gt;
fmt.Println("*length value", length)&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Note&lt;/strong&gt; After changing the pointer value i.e width, the value of the length also changes since they are in the same address,  This is one of the reasons why you should use a pointer instead of a value, i.e if you want to make a change to a variable or update it and make it "persist".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; &lt;br&gt;
When passing an argument by value:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
// Create a function called length that returns a number&lt;br&gt;
func  length(x int) {&lt;br&gt;
x =  12&lt;br&gt;
}&lt;br&gt;
func  main() {&lt;br&gt;
x :=  5&lt;br&gt;
length(x)&lt;br&gt;
fmt.Println(x) // x is still 5&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When passing an argument using pointers.&lt;br&gt;
&lt;code&gt;&lt;br&gt;
func  length(x *int) {&lt;br&gt;
*x =  12&lt;br&gt;
}&lt;br&gt;
func  main() {&lt;br&gt;
x :=  5&lt;br&gt;
length(&amp;amp;x)&lt;br&gt;
fmt.Println(x) // x will return 12&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
From this I hope you have a brief understanding on the use of pointers.&lt;/p&gt;

&lt;p&gt;If you want to read more on pointers you can check out the following links.&lt;br&gt;
&lt;a href="%5Bhttps://www.youtube.com/watch?v=yEiaCx0fR9k%5D(https://www.youtube.com/watch?v=yEiaCx0fR9k)"&gt;GopherConUk&lt;/a&gt;&lt;br&gt;
&lt;a href="%5Bhttp://www.golang-book.com/books/intro/8%5D(http://www.golang-book.com/books/intro/8)"&gt;golang-book&lt;/a&gt;&lt;br&gt;
&lt;a href="%5Bhttps://www.digitalocean.com/community/conceptual_articles/understanding-pointers-in-go%5D(https://www.digitalocean.com/community/conceptual_articles/understanding-pointers-in-go)"&gt;gopher-guides&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>pointers</category>
    </item>
    <item>
      <title>My first gatsby site</title>
      <dc:creator>vincent muthabuku</dc:creator>
      <pubDate>Mon, 25 Mar 2019 01:45:11 +0000</pubDate>
      <link>https://forem.com/vmuthabuku/my-first-gatsby-site-53g7</link>
      <guid>https://forem.com/vmuthabuku/my-first-gatsby-site-53g7</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;I have been coding inconsistently for the past eight months and working on other none coding activities, I currently built my first gatsby site apart from being my first gatsby site it is also the first site I have built using a javascript framework. I prefer working on backend projects but working on my first gatsby site has been interesting.&lt;/p&gt;

&lt;p&gt;I built this simple site using gatsby and semantic-ui. It took me two days I had to level up especially on React as it had been a while since I have used it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gatsby documentation
&lt;/h2&gt;

&lt;p&gt;The gatsby documentation is extremely easy and user-friendly and I would advise anyone who would wish to create a gatsby site to consider using the documentation as some of the docs are accompanied by videos for those who prefer using videos.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gatsby Development
&lt;/h3&gt;

&lt;p&gt;For me, it was not as smooth as I thought it would since the guys who had used it seemed to find it easy to use and most of them completed the projects in two to three hours for me it took two days.&lt;br&gt;
But building the blog was extremely easy since it used the markdown concept that simplified everything especially for a newbie like myself.&lt;br&gt;
Creation of links and new pages was also very easy credits to the gatsby team.&lt;br&gt;
The fact that it uses React and es6 is also an added advantage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Personal thoughts
&lt;/h3&gt;

&lt;p&gt;For me, I would definitely use gatsby again due to the ease and simplicity of building these sites.&lt;br&gt;
Right now I am working on my skills on graphql as I came to understand one of the pillars of gatsby is that it uses graphql and understanding it would be a big plus for me and anyone who would love to learn and use gatsby.&lt;/p&gt;

&lt;h3&gt;
  
  
  Biggest Challenge
&lt;/h3&gt;

&lt;p&gt;My biggest challenge was deploying my app to github pages, the build was passing but my gh-pages link was returning a blank page with only the read-me info, I deployed it on netlify as it was easier.&lt;/p&gt;

</description>
      <category>gatsby</category>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
