<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shubham Saurav on Medium]]></title>
        <description><![CDATA[Stories by Shubham Saurav on Medium]]></description>
        <link>https://medium.com/@shubhamsaurav?source=rss-d6edbd131b8f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*tT5_9QQeEELxp1zpLCjWqg.jpeg</url>
            <title>Stories by Shubham Saurav on Medium</title>
            <link>https://medium.com/@shubhamsaurav?source=rss-d6edbd131b8f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 13:40:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shubhamsaurav/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Day 15 of #30DaysOfCode | FizzBuzz and Interfaces In Go]]></title>
            <link>https://medium.com/@shubhamsaurav/day-15-of-30daysofcode-fizzbuzz-and-interfaces-in-go-4c3e8fcc62c0?source=rss-d6edbd131b8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c3e8fcc62c0</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <dc:creator><![CDATA[Shubham Saurav]]></dc:creator>
            <pubDate>Sun, 12 Jul 2020 17:26:36 GMT</pubDate>
            <atom:updated>2020-07-12T17:32:07.856Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*dnw7iQ6PCgXxT-mm.png" /></figure><p>Hey YOU! How are you doing today? I hope that you are having a fantastic day. I myself am having an amazing day. Today is the Day 15 of #30DaysOfCode challenge and it means that I have completed 50% of the challenge which is really cool. For this special day, I decided to dive into interfaces in Go. So, let’s talk about that for a bit and then we will look into the example of fizzbuzz coding solution.</p><p>Interfaces are really amazing. It helps you to implement polymorphism in Go. As you know that Go is not an object-oriented programming language and as a result, we don’t have classes and objects in Go. But we still need to write maintainable and scalable software and the Interfaces allows us to do so. So, <strong>What is Interface?</strong></p><h3>What is Interface?</h3><p>An interface is a collection of method signatures that a Type can implement. Hence interface defines the behaviour of the object of the type which implements its method signature.<br> This is the technical definition of Interfaces. And today, I don’t understand it fully. I still need to learn more about it to be able to share with somebody. So, I am going to leave the interfaces for today and hopefully, I will have enough understanding to share about it tomorrow.</p><p>Now, let’s talk about the fizzbuzz coding challenge. What is it and then I will take a look at the solution. Basically, Its a programming task where if the number is divisible by 3 and 5 both then you have to return ‘fizzbuzz’, if the number is divisible by 3 only then you have to return ‘fizz’, if the number is divisible by 5 only then you have to return ‘buzz’ and if the number is not divisible by 3 or 5 then you have to return none. I don’t know if this is actually the real task but this is the task which I know of. So the solution will be for this specific task and not the ones which are floating around the internet.</p><p>Now, let’s take a look at the code and try to understand it. I won’t go over each line because the code is self explanatory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZYW8pB5ANfdfgkEHy4pc-g.png" /></figure><p>Here we have defined a function which takes a number as a parameter and then we are checking for each of the cases using the conditionals. In the first if conditional, we are checking if the number is divisible by 3 and 4 both and if the number is then we are returning &#39;fizzbuzz&#39;. In the second else if conditional, we are checking if the number is divisible by 3 and if it is then we will return &#39;fizz&#39;. In the third else if conditional, we are checking if the number is divisible by 5 and if it is then we are returning &#39;buzz&#39;. And if none of the cases is true then we will return &#39;none&#39;.</p><p>Alright! That was all about interfaces and fizzbuzz coding challenge and I hope that you loved it. If you loved it, please don’t forget to follow me here.</p><p>Connect With Me:<br> Youtube: <a href="https://www.youtube.com/c/ShubhamSauravYT">ShubhamSauravYT</a>.<br> Twitter:<a href="https://www.twitter.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Instagram:<a href="https://www.instagram.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Facebook:<a href="https://facebook.com/hiShubhamSaurav">@hiShubhamSaurav</a></p><p><em>Originally published at </em><a href="https://dev.to/shubhamsaurav/day-15-of-30daysofcode-fizzbuzz-and-interfaces-in-go-3ab1"><em>https://dev.to</em></a><em> on July 12, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c3e8fcc62c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 14 of #30DaysOfCode | Functions in Go(golang)]]></title>
            <link>https://medium.com/@shubhamsaurav/day-14-of-30daysofcode-functions-in-go-golang-cb357944912?source=rss-d6edbd131b8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb357944912</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[code-newbie]]></category>
            <dc:creator><![CDATA[Shubham Saurav]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 17:54:01 GMT</pubDate>
            <atom:updated>2020-07-11T17:56:39.457Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*mX08WvG0b9p1iK6k.png" /></figure><p>Hey awesome people! How are you doing today? Are you having fun and enjoying this wonderful gift called life? Did you learn anything today?<br> You know, there is fun in learning new things, there is enjoyment in learning new things. I hope that you are enjoying as well as learning new things every day. Now, without any further ado let’s talk about what I learned today.</p><p>Today, I dived into the realm of functions and methods in Go. It was amazing. I learnt about the anonymous function. I learnt about the first-order function and passing these functions as parameters, returning multiple return values. Then I learnt about writing Variadic functions in Golang. These were the new things I learnt about functions in Go.</p><p>Now, for today’s coding example, I would like to share a simple variadic function code with you. Here is the code example, take a look at it and then we will talk about what it does how it works?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v97AgvStQFI-b_o-TkclTw.png" /></figure><p>The sum function returns the sum of all the numbers that are passed as a parameter. This is a Variadic function and in the function call, we are printing the return value. Now let&#39;s talk about the code part of the example.<br> This function will take an arbitrary number of ints as arguments. It is possible because we used the... operator before int. We have a variable named result to store the sum. We are looping through the nums and in the loop we are adding each element to the result variable. When the loop ends, we are returning the result variable as the return value. In the main function, we are calling the sum function and the return value is then printed in the main function. It&#39;s as simple as that.</p><p>Alright! That’s all for today. Do follow me for more posts like this. Also, after the completion of the challenge, I will be covering the entire fundamentals of the Go Programming Language in great detail. So be on the lookout for that.<br> Thanks.</p><p>Connect With Me:<br> Youtube: <a href="https://www.youtube.com/c/ShubhamSauravYT">ShubhamSauravYT</a>.<br> Twitter:<a href="https://www.twitter.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Instagram:<a href="https://www.instagram.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Facebook:<a href="https://facebook.com/hiShubhamSaurav">@hiShubhamSaurav</a></p><p><em>Originally published at </em><a href="https://dev.to/shubhamsaurav/day-14-of-30daysofcode-functions-in-go-golang-5e80"><em>https://dev.to</em></a><em> on July 11, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb357944912" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 13 of #30DaysOfCode | Loops, Defer, Panic, Recover and Pointers In Go(golang)]]></title>
            <link>https://medium.com/@shubhamsaurav/day-13-of-30daysofcode-loops-defer-panic-recover-and-pointers-in-go-golang-2b81764b7b52?source=rss-d6edbd131b8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b81764b7b52</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[code-newbie]]></category>
            <dc:creator><![CDATA[Shubham Saurav]]></dc:creator>
            <pubDate>Fri, 10 Jul 2020 17:30:34 GMT</pubDate>
            <atom:updated>2020-07-10T17:32:56.771Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Ejxrn3I_vzyf0BgG.png" /></figure><p>Hey awesome people! How are you doing today? Today is the Day 13 of #30DaysOfCode and as part of the daily challenge, I learnt how to use defer, panic, recover and Pointers is Golang. So, let’s talk about them in detail.</p><h3>Loops in Go</h3><p>In Golang, we only have a single loop which can be implemented in more than one ways. The for loop has there part. The first one being the init statement. It is the part where we initialize our iterator variable. It is executed before the first iteration. The second part is the condition expression. It is the part where we put our conditional logic. It is executed before every iteration. If the condition is true then the iteration will be done again and if the condition results false then the loop will end. The third part is the post statement. It is the part where we increment or decrement our iterator variable. This part is executed at the end of every iteration. After the post part, the condition statement evaluates again if the value of the conditional statement is false, then the loop ends. This is a very brief introduction to Loops in Go. And I will write a detailed post on Loops In Golang after the challenge is complete.</p><p>Here are the two way to write a for loop in Go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5M3vAX2t4o6PqpZ93gsn1g.png" /></figure><p>Defer, Panic and recover are the three things in Go that need a separate blog post for themselves. We can’t really discuss these three topics in 10 lines in a blog post. One thing I would like to point out though is that these three have everything to do with error handling in Go. And we will discuss these in great detail in a separate post.</p><p>Now let’s talk a bit about Pointers in Go. If you have been following me from Day 1 then you would know that I have written about pointers in the near past. Actually, I have written about it in two separate posts. I am linking those two post here. Also, when the #30DaysOfCode challenge is complete, I will be writing about the fundamentals of Go Programming Language. So make sure that you follow me for that.</p><p><a href="https://dev.to/shubhamsaurav/day-4-of-30daysofcode-pointers-and-maps-in-go-golang-52ni">Pointers and Maps In Go | Day 4 of #30DaysOfCode</a><br><a href="https://dev.to/shubhamsaurav/day-6-of-30daysofcode-pointers-and-new-in-golang-bfa">Pointers and new() In Go | Day 6 of #30DaysOfCode</a></p><p>Alright! That’s enough for today. It was a lot to learn for me and hopefully, I will continue to enjoy these long working days.</p><p>Connect With Me:<br> Youtube: <a href="https://www.youtube.com/c/ShubhamSauravYT">ShubhamSauravYT</a>.<br> Twitter:<a href="https://www.twitter.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Instagram:<a href="https://www.instagram.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Facebook:<a href="https://facebook.com/hiShubhamSaurav">@hiShubhamSaurav</a></p><p><em>Originally published at </em><a href="https://dev.to/shubhamsaurav/day-13-of-30daysofcode-loops-defer-panic-recover-and-pointers-in-go-golang-41ed"><em>https://dev.to</em></a><em> on July 10, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b81764b7b52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 12 of #30DaysOfCode | Conditionals In Go (golang)]]></title>
            <link>https://medium.com/@shubhamsaurav/day-12-of-30daysofcode-conditionals-in-go-golang-5d1d99a27c59?source=rss-d6edbd131b8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d1d99a27c59</guid>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Shubham Saurav]]></dc:creator>
            <pubDate>Thu, 09 Jul 2020 17:27:59 GMT</pubDate>
            <atom:updated>2020-07-09T17:30:51.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*-YC56UO7_2z-DBn_.png" /></figure><p>Hey wonderful people! How are you doing today? I hope you are healthy in the pandemic. I hope that you are living your life and learning new things every day. Today is Day 12 of #30DaysOfCode challenge and I learnt about conditionals in Go.</p><p><em>Whenever you are writing a program, you don’t want to execute from the first line to the last line. You want to have control over your program. You want to run some lines code only when a certain situation is met and the conditionals help you to do so.</em></p><p>The conditionals help you to control the flow of your program. In Golang, we have many conditionals. These conditionals are very similar to other C like languages. Let’s talk about them one by one.</p><ol><li>If conditional: The if conditional executed the code inside its block when a condition is true.</li><li>If-Else conditional: The if-else conditional executes the code inside the if block when a certain condition is true and it executed code in else block when the condition is false.</li><li>If, Else-If and Else conditional: The if, else if, else conditional execute the code in if block when the if condition is true. If the condition is not true, it moves to the else if block and executes the code in its block if the condition in else if is true. If none of the if and else if conditions are true, it execute the code in the else block.</li><li>Switch Case statement: The switch case statement is used to select one of many blocks of code to be executed. It executes the code of a case when the condition for that case is true.</li></ol><p>These conditionals work almost the same in practice in Go as they work in other C-like languages. Here is a simple example of if, else if, else in Go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hpWgvfb92EIr_c-fjdn6qA.png" /></figure><p>Alright! That’s gonna be it for today’s post.<br> Bye.</p><p>Connect With Me:<br> Youtube: <a href="https://www.youtube.com/c/ShubhamSauravYT">ShubhamSauravYT</a>.<br> Twitter:<a href="https://www.twitter.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Instagram:<a href="https://www.instagram.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Facebook:<a href="https://facebook.com/hiShubhamSaurav">@hiShubhamSaurav</a></p><p><em>Originally published at </em><a href="https://dev.to/shubhamsaurav/day-12-of-30daysofcode-conditionals-in-go-golang-4684"><em>https://dev.to</em></a><em> on July 9, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d1d99a27c59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 11 of #30DaysOfCode | Arrays and Slices In Golang (Part 2)]]></title>
            <link>https://medium.com/@shubhamsaurav/day-11-of-30daysofcode-arrays-and-slices-in-golang-part-2-87ecba0bfd7f?source=rss-d6edbd131b8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/87ecba0bfd7f</guid>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[code-newbie]]></category>
            <dc:creator><![CDATA[Shubham Saurav]]></dc:creator>
            <pubDate>Tue, 07 Jul 2020 17:46:07 GMT</pubDate>
            <atom:updated>2020-07-07T17:48:11.950Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*PPLU1lHudDC8vuGO.png" /></figure><p>You are better than you think you are. I started this #30DaysOfCode challenge and I am going through it. I am learning every day and actually achieving something. People say that <em>Consistency is the key to success</em>. It is true and you can be consistent too. There is nothing special in me. We are more or less the same. You can also do it. You can also start a challenge like this and finish it. You have got the power, the energy and the passion. You just need to recognise it. And if you need any help then comment below and I’ll do my best to help you.</p><p>Now let’s move on to the post.</p><p>Today is Day 11 of the challenge and I would like to share more about the array and slices in Golang. In the last post, we learnt about what arrays and slices are and the difference between them. In this one, we will learn how we can define them and then some of the operations that we can perform on them.</p><p>Firstly, let’s just take a look at the example below before reading any further.</p><figure><img alt="Array and Slice example in golang" src="https://cdn-images-1.medium.com/max/1024/1*co0-Z1rt7LpR9tE23ISTDw.png" /></figure><p>Previously, we learned that we cannot add more element to an array but we can add more element to the slice and we can do this using the append() function. In the append function, we need to pass the slice in the first parameter and in the second parameter, we need to pass the value or values that we want to append. The append function will add the elements to the slice and return a new slice. You can store the new slice in the variable and then can use it later. Take a look at the example to understand how it works.</p><p>The second operation I wanna talk about is changing the data. This one is very simple and works with both arrays and slices. Just write the slice or array name and pass the index in the square bracket and then use the ‘=’ to change the data. It’s very simple and easy. Just take a look at the example and you will get it.</p><p>The third thing I wanna talk about is reading the data of a single element. Again, it’s very simple. Just use the array or the slice name and pass the index of the element you want to read and you will be able to read the data of that specific element.</p><p>The last thing I wanna talk about is counting the length of the arrays or slices. This is also very easy to do. You can use the len() function to count the length of an array or a slice. Just call the len() and pass the array or slice as the parameter. This will return the length of the array or slice that’s passed in. Take a look at the example to learn how to do it.</p><p>These are the common operations that you can perform with these collection types and if you wanna learn more about them then let me know in the comments below.</p><p>Alright! That’s enough for this post and I’ll see you in the next one. Bye.</p><p>Connect With Me:<br> Youtube: <a href="https://www.youtube.com/c/ShubhamSauravYT">ShubhamSauravYT</a>.<br> Twitter:<a href="https://www.twitter.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Instagram:<a href="https://www.instagram.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Facebook:<a href="https://facebook.com/hiShubhamSaurav">@hiShubhamSaurav</a></p><p><em>Originally published at </em><a href="https://dev.to/shubhamsaurav/day-11-of-30daysofcode-arrays-and-slices-in-golang-part-2-png"><em>https://dev.to</em></a><em> on July 7, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87ecba0bfd7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 10 of #30DaysOfCode | Basics of Array and Slice in Go(golang)]]></title>
            <link>https://medium.com/@shubhamsaurav/day-10-of-30daysofcode-basics-of-array-and-slice-in-go-golang-3ad5841803bc?source=rss-d6edbd131b8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ad5841803bc</guid>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[golang-development]]></category>
            <dc:creator><![CDATA[Shubham Saurav]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 18:24:53 GMT</pubDate>
            <atom:updated>2020-07-06T18:26:30.307Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*HUpqWejIde-z2NR3.png" /></figure><p>Hey beautiful person! How are you doing today? Hopefully, you are doing great and having loads of fun. I myself am enjoying the #30DaysOfCode challenge and having loads and loads of fun learning new things every day. Today is the Day 10 of challenge and I am super happy that I have completed the 33.33% of the challenge and I have a lot to share with you so read on.</p><p>Today, I dived a bit deeper into arrays and slices in Golang and I would like to share the basic with you. The Array and Slice are key data type in Go. They are basically a collection type. They are used to store a collection of data. They are similar to List in Python, Array in Swift, Java, C++ and many other programming languages.</p><p>The arrays and slices are used to store a collection of similar-related data. Suppose that you want to store the names of all the friends you have. Then you would use an array or slice to store the collection of names of your friends. Now, let’s talk about each of the types and the key differences between them.</p><h3>A look into Arrays in Golang</h3><p>Arrays are a collection data type in Go Programming Language. Arrays in Go have fixed length and once they are defined you cannot add more element into it. They can be used to store data of similar types. Storing similar type means that you can only store data of similar data type. For eg: you can store a collection of int, or a collection of float32, or a collection of string in arrays but you can’t store a mixed collection of int, float32 and string.<br> Arrays are also a value type. Being a value type means that the variable holds the value in its memory space. They don’t store the address where the value is stored. So, when you copy an array then a completely new array is created which holds the copied value in its own memory space and not the address where the value is stored in memory. If you change the element of the one array then it will have no effect on the other array. The value in the other array won’t be changed.</p><h3>A look into Slices in Golang</h3><p>Slices are a collection data type in Go Programming Language. The slices are a lot similar to arrays in Golang. They also can be used to store data of similar types. You can’t also have a mixed collection of data in slices just like you can’t have it in arrays. But there is a difference between the two.</p><h3>Difference between Arrays and Slices in Golang</h3><p>The main key difference between arrays and slices is that slices don’t have a fixed length so, once they are defined you can add more elements to the slice whereas you cannot add more element to the array after you have defined it. Also, the slices are reference type in Go. So the slices don’t store the values directly. They only store the address where the values are being stored. If you copy a slice then the new slice will copy the address where the value is stored and when you change an element then the values in both the slices will be changed.</p><p>Alright! that’s enough for this post and in the next one, we will dive deeper into arrays and slices and will take a look at the operations that can be performed on them.</p><p>Connect With Me:<br> Youtube: <a href="https://www.youtube.com/c/ShubhamSauravYT">ShubhamSauravYT</a>.<br> Twitter:<a href="https://www.twitter.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Instagram:<a href="https://www.instagram.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Facebook:<a href="https://facebook.com/hiShubhamSaurav">@hiShubhamSaurav</a></p><p><em>Originally published at </em><a href="https://dev.to/shubhamsaurav/day-10-of-30daysofcode-basics-of-array-and-slice-in-go-golang-2cmj"><em>https://dev.to</em></a><em> on July 6, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ad5841803bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 9 of #30DaysOfCode | Little trick to make API secure]]></title>
            <link>https://medium.com/@shubhamsaurav/day-9-of-30daysofcode-little-trick-to-make-api-secure-f25ade690d0d?source=rss-d6edbd131b8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f25ade690d0d</guid>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Shubham Saurav]]></dc:creator>
            <pubDate>Sun, 05 Jul 2020 16:15:29 GMT</pubDate>
            <atom:updated>2020-07-05T16:18:27.429Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*dyum9EnrImlySoyJ.png" /></figure><p>Hey awesome person! Thank you for reading this post. I am super happy to have you here. Today is the 9th day of my #30DaysOfCode challenge. The challenge has been so much fun for me that I can’t explain in words. I have learnt and grown a lot in the last 9 days. You all have been very supportive in my journey so thank you for that too.</p><p>Now, today I would like to talk about a simple trick that can make our API very secure. Whenever you are writing code for user signup, you should keep this neat little trick in mind. The trick is really helpful and can protect you from attackers. Enough of the talking, let’s just take a look at the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_0K6gMnRKwwv4CIblU9TZQ.png" /></figure><p>Both the example works and both will create a user but there is a serious problem with the first example. In the first example, we are just directly creating a user from all the data sent by the client. This is very unsecure because there are many other fields that you don’t want the client to set. For example, you don’t want the client to set the passwordResestToken or passwordResetExpiryDate but in the first example, the client will be able to do so because we are not filtering or processing the data. The client will be able to set the fields which they should be. But this can be fixed easily with the second example approach.</p><p>In the second example, we are creating a user only from the fields which we want. We are deconstructing name, email and password field from the data send by the client and we are creating a user from these fields only. This way the client wouldn’t be able to set the passwordResestToken or passwordResetExpiryDate or any fields which are not required in registering user. So, always choose the second example over the first example.</p><p>This simple trick can really save you from attackers. But this simple trick does not mean that you are safe from all the other vulnerability. You still need to learn more about API security and I am pretty sure that you will.</p><p>Alright! That’s all for today. Don’t forget to like and share this post if you found it useful.<br> This is me, Signing Off!</p><p>Connect With Me:<br> Youtube: <a href="https://www.youtube.com/c/ShubhamSauravYT">ShubhamSauravYT</a>.<br> Twitter:<a href="https://www.twitter.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Instagram:<a href="https://www.instagram.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Facebook:<a href="https://facebook.com/hiShubhamSaurav">@hiShubhamSaurav</a></p><p><em>Originally published at </em><a href="https://dev.to/shubhamsaurav/day-9-of-30daysofcode-little-trick-to-make-api-secure-2549"><em>https://dev.to</em></a><em> on July 5, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f25ade690d0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 8 of #30DaysOfCode | Building Restful APIs]]></title>
            <link>https://medium.com/@shubhamsaurav/day-8-of-30daysofcode-building-restful-apis-e65a41205579?source=rss-d6edbd131b8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e65a41205579</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Shubham Saurav]]></dc:creator>
            <pubDate>Sat, 04 Jul 2020 16:39:22 GMT</pubDate>
            <atom:updated>2020-07-04T16:41:42.542Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*m-Kls9TlIiTxygvx.png" /></figure><p>Hey everybody! Firstly, I would like to thank you for reading this post. I am thankful to all of you who is following me in my journey of becoming a better programmer and a better person.</p><p>Today is the 8th day of my #30DaysOfCode challenge. For the last 7 days, I was mostly focused on learning and writing Go code but today decided to focus my entire time in building the Journal API which I talked about in the last post. So, let’s talk about the tech stack I am using to write my Restful API.</p><p>I am building the API with NodeJs and MongoDB. I am using ExpressJS and mongoose to make development easier. For dealing with user authentication, I am using bcryptyjs and jsonwebtoken. There are many other dependencies but these are the main ones.</p><p>Now, comes the golden question.<br><strong>How can you build a Restful API?</strong><br> There are many options available in the market for building Restful APIs. There are the languages that I know of which can be used to build Restful APIs:- Javascript, Python, Ruby, Php, and Golang. There are not the only options but the ones I know of. Now, let’s talk about how can these languages be used to build a Restful API.<br> Javascript can be used in the backend with NodeJs. You can also choose to build an API with Javascript framework like ExpressJS, AdonisJs. These frameworks are really popular and have a demand in the market.<br> Python can be used with Flask or Django Rest framework. You can use Django Rest Framework for rapid development.<br> Ruby was a popular choice a few years ago and it still is a very capable language. You can use the Ruby on Rails to build an API very quickly.<br> Php is a very popular choice. Many developer don’t like Php but it’s still a very capable technology. You can use Laravel or any other Php framework to build an API.<br> Golang can also be used to build APIs. In fact, it has an inbuilt library for that. You can also use frameworks like Fiber or Buffalo to build your API.</p><p>All these languages are very capable for this task. But that’s not the only thing that you need. You also need a database to store data. MongoDB, MySql, PostgreSQL, etc are popular choice. Choose the one that suits your need and you will never go wrong.</p><p>Alright! that’s gonna be it for today and hopefully, I will see you in the next post.</p><p>Connect With Me:<br> Youtube: <a href="https://www.youtube.com/c/ShubhamSauravYT">ShubhamSauravYT</a>.<br> Twitter:<a href="https://www.twitter.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Instagram:<a href="https://www.instagram.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Facebook:<a href="https://facebook.com/hiShubhamSaurav">@hiShubhamSaurav</a></p><p><em>Originally published at </em><a href="https://dev.to/shubhamsaurav/day-8-of-30daysofcode-1fpp"><em>https://dev.to</em></a><em> on July 4, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e65a41205579" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 7 of #30DaysOfCode | lifetime of variables in golang]]></title>
            <link>https://medium.com/@shubhamsaurav/day-7-of-30daysofcode-lifetime-of-variables-in-golang-4c9505ce51d6?source=rss-d6edbd131b8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c9505ce51d6</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[golang-development]]></category>
            <dc:creator><![CDATA[Shubham Saurav]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 17:24:50 GMT</pubDate>
            <atom:updated>2020-07-03T17:29:14.165Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*-6uFjWA6UJZYpZll.png" /></figure><p>Today is the 7th day of my #30DaysOfCode challenge. I have so many exciting things to share with you guys. So let’s just get into it.</p><p>The first thing that I would like to share is about the lifetime of the variables. Some of you know that Golang is a garbage-collected language. Being a garbage collected language means that the memory will be automatically reclaimed by the language itself. The developers don’t have to worry about collecting or reclaiming the memory in code manually. The language will do that for you. But this doesn’t mean that developers don’t need to think about memory or learn about the lifetime of variables. To write efficient programs, developers still need to be aware of the lifetime of variables. So, let’s learn about that.</p><p><strong>What is the lifetime of a variable?</strong><br> The lifetime of the variable is the time interval in which the variable exists as the program runs.</p><p><strong>The lifetime of variables in Golang:</strong><br> The package-level variable exists during the entire execution of the program while the local variable exists for a limited period of time. A local variable is created each time the declaration is executed and it lives on until it becomes unreachable and then, their memory is reclaimed. The function parameters and loop iterator variables are examples of local variables. The function variables are created each time their function is called. The loop iterator variables are created each time the loop begins. And when the variables become unreachable, the Go compiler reclaims their memory.</p><p>Okay. That was a brief introduction to the lifetime of variables in Go. Now, let’s talk about a pet-practice project I am working on.</p><p>Some of you may know that I am also learning to write Restful APIs using NodeJs. And today, I have started working on a Journal API. At the moment, this project is just for fun and practice. Nothing serious but the project will be full packed though. The API will have all the functionality that any production project has. And I will be making it open source in the end.</p><p>Alright! That’s enough talk for today. And hopefully, I will see you guys tomorrow.</p><p>Connect With Me:<br> Youtube: <a href="https://www.youtube.com/c/ShubhamSauravYT">ShubhamSauravYT</a>.<br> Twitter:<a href="https://www.twitter.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Instagram:<a href="https://www.instagram.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Facebook:<a href="https://facebook.com/hiShubhamSaurav">@hiShubhamSaurav</a></p><p><em>Originally published at </em><a href="https://dev.to/shubhamsaurav/day-7-of-30daysofcode-lifetime-of-variables-in-golang-4ggf"><em>https://dev.to</em></a><em> on July 3, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c9505ce51d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 6 of #30DaysOfCode | pointers and new() in golang]]></title>
            <link>https://medium.com/@shubhamsaurav/day-6-of-30daysofcode-pointers-and-new-in-golang-8680c7ae6b8d?source=rss-d6edbd131b8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8680c7ae6b8d</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <dc:creator><![CDATA[Shubham Saurav]]></dc:creator>
            <pubDate>Wed, 01 Jul 2020 17:44:11 GMT</pubDate>
            <atom:updated>2020-07-01T17:46:43.586Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*8KvdAnvOXgenCdt9.png" /></figure><p>Today is the 6th day of #30DaysOfCode challenge. I started my day by reading the Go Programming Langauge Book by Alan A. A. Donovan and Brian W. Kernighan. And I would like to share what I have learned today with you so let’s just jump right into the code.</p><p>First, Take a look at the image below and try to understand the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5-cZ_uItOeWMJ3fMFF-USg.png" /></figure><p>There are multiple ways to declare a variable and I learnt a new way today. You can also declare a variable using new() function. The new function takes the type(such as int bool string) as an argument and it returns the address of the memory location. In the example, the new function is creating an integer type variable and it is returning the address. In the line just below, we are accessing the value of the variable using the * symbol.</p><p>There is just one thing that I want to learn from this post at least, which is that the * symbol is used to access the value and &amp; is used to access the address of the variable in the memory. And if you understand this then it will help you in understanding how pointers work. But just keep in mind that when * is used before a type (such as int, bool or string), it means a different thing. We will talk about this in my later posts. So don’t worry about that for now. Just know that in this example, it means that the function takes a pointer of type int.</p><p>In the example, we have a function which increments the value of the variable. The function takes a pointer of type int as an argument. We are using the * symbol to access the value and we are returning the value. In the main function, we are using &amp; symbol to access the address and we are passing the address in the incr() function. The function runs and it increments the value of the variable by 1. And that’s all that our program does.<br> I hope that it’s all clear to you. If you have any question then feel free to ask in the comments below.</p><p>Alright! That’s all for today and I will see you in my next post. Bye.</p><p>Connect With Me:<br> Youtube: <a href="https://www.youtube.com/c/ShubhamSauravYT">ShubhamSauravYT</a>.<br> Twitter:<a href="https://www.twitter.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Instagram:<a href="https://www.instagram.com/hiShubhamSaurav">@hiShubhamSaurav</a><br> Facebook:<a href="https://facebook.com/hiShubhamSaurav">@hiShubhamSaurav</a></p><p><em>Originally published at </em><a href="https://dev.to/shubhamsaurav/day-6-of-30daysofcode-pointers-and-new-in-golang-bfa"><em>https://dev.to</em></a><em> on July 1, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8680c7ae6b8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>