<?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 Kishore M G on Medium]]></title>
        <description><![CDATA[Stories by Kishore M G on Medium]]></description>
        <link>https://medium.com/@kishoremg?source=rss-5d89dec82f37------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*JXcl0ypRKUBR1dSB</url>
            <title>Stories by Kishore M G on Medium</title>
            <link>https://medium.com/@kishoremg?source=rss-5d89dec82f37------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 15:21:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kishoremg/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[Want to know how docker evolved?]]></title>
            <link>https://kishoremg.medium.com/want-to-know-how-docker-evolved-0f1494ce38b5?source=rss-5d89dec82f37------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f1494ce38b5</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Kishore M G]]></dc:creator>
            <pubDate>Thu, 25 Jul 2024 06:02:25 GMT</pubDate>
            <atom:updated>2024-07-25T06:02:25.783Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Hello, Tech Aficionados!</strong></p><p>Welcome to the first part of our Docker series!</p><p>In this segment, we will explore the evolution of deployment practices and how Docker emerged as a revolutionary tool in the tech world. We’ll journey through the history of software deployment, from traditional methods to modern containerization. By understanding the challenges and innovations that led to Docker’s creation, you’ll gain a solid foundation for appreciating its impact and potential. Let’s embark on this fascinating exploration of Docker’s origins and the evolution of deployment technology!</p><h3>Evolution of deployments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d6xpHhNod2Fkkkt-nnxX1w.jpeg" /><figcaption>Evolution of deployment — Docker</figcaption></figure><p>While Docker offers numerous advantages for development and deployment, understanding these benefits requires a look at traditional deployment methods and how they led to Docker’s evolution.</p><p>In terms of evolution, so far, we have three stages of evolution</p><ol><li>Traditional deployment</li><li>Virtualized deployment</li><li>Container deployment</li></ol><h3>Traditional Deployment</h3><p>To make it simple, let us consider a physical computer setup where if we want to play a game, we used to install the necessary drivers, software which were required by the game to consume and then run the game to enjoy the hour! Right!!!</p><p>The same way, the traditional deployment is done over a physical server where the desired application is installed and deployed with all its dependencies.</p><h4><strong>Disadvantages:</strong></h4><ol><li><strong>Cost issue:</strong> The <strong>cost</strong> required to setup a server is too <strong>high</strong>.</li><li><strong>Resource issue:</strong> The resource allocation can’t be manipulated for the applications running out there.</li><li><strong>Scalability issue: </strong>In terms of higher traffic, the resources can’t be scaled up as the physical server should be installed with additional hardware to increase the resource like memory and CPU.</li><li><strong>Crashing issue: </strong>In case of sudden spike over the traffic, if the server can’t with the existing resource, then system might hang and end up in downtime.</li><li>And even there are lot more disadvantages like lack of disaster recovery, maintenance and mainly security concern too.</li></ol><h3>Virtualized Deployment:</h3><p>As we have seen above, the traditional deployment has many disadvantages which led to the evolution of virtualized deployment. In virtualized deployment, major issues such as cost, resource management, and scalability were effectively addressed.</p><p>Here, again we do have a physical server but instead of running an application directly on the server, we utilize a hypervisor to create multiple virtual machines (VMs) on that single physical server.</p><p>Now, What is meant by hypervisor? 🤔</p><p>A hypervisor, also known as a virtual machine monitor (VMM), is a piece of software, firmware, or hardware that creates and runs virtual machines. Each VM operates as a fully independent computer, with its own operating system and applications. The hypervisor manages these VMs, ensuring they share the underlying physical hardware resources efficiently.</p><p>With this ability of having multiple fully independent computer within one physical server, we were able to run different applications in a single physical server. Not only that, it also helped us to manage the resource distribution between VMs which provided us the ability to resolve the scalability issue.</p><h4><strong>Pros:</strong></h4><ol><li><strong>Resource Optimization<br>- Efficient Utilization</strong>: Virtualized environments maximize hardware utilization by running multiple VMs on a single physical server, ensuring that resources such as CPU, memory, and storage are used more efficiently.<br>- <strong>Reduced Idle Time</strong>: Physical servers are often underutilized when dedicated to a single application. Virtualization reduces idle resources, making overall IT operations more cost-effective.</li><li><strong>Scalability<br>- Easy Expansion</strong>: Scaling up is straightforward in a virtualized environment. New VMs can be created quickly to meet increased demand without the need for additional physical hardware.<br>- <strong>Elasticity</strong>: Resources can be dynamically allocated to VMs based on current needs, allowing for flexible and responsive scaling.</li><li><strong>Isolation and Security<br>- Improved Security</strong>: Each VM operates independently, which means that if one VM is compromised, it doesn’t necessarily affect others on the same physical server.<br>- <strong>Fault Isolation</strong>: Issues in one VM, such as crashes or malware, do not impact the performance or stability of other VMs.</li><li><strong>Flexibility and Manageability<br>- Ease of Maintenance</strong>: VMs can be easily migrated between physical servers, facilitating maintenance and upgrades with minimal downtime.<br>- <strong>Disaster Recovery</strong>: Virtualized environments support efficient backup and recovery strategies. VMs can be quickly backed up, cloned, or restored in case of failures.</li><li><strong>Cost Efficiency<br>- Lower Hardware Costs</strong>: Fewer physical servers are needed, reducing capital expenditure on hardware.<br>- <strong>Reduced Operational Costs</strong>: Lower power consumption, cooling needs, and physical space requirements contribute to overall cost savings.</li></ol><h4><strong>Cons:</strong></h4><ol><li><strong>Initial Setup Costs<br>- Infrastructure Investment</strong>: Setting up a virtualized environment can require a significant initial investment in virtualization software, more powerful servers, and storage solutions.<br>- <strong>Complex Licensing</strong>: Licensing costs for virtualization software can be high, and managing these licenses can be complex.</li><li><strong>Performance Overhead<br>- Resource Contention</strong>: Multiple VMs sharing the same physical resources can lead to contention, affecting performance if not managed properly.<br>- <strong>Latency Issues</strong>: The additional layer of virtualization can introduce latency, impacting the performance of certain applications, especially those that are resource-intensive.</li><li><strong>Security Risks<br>- Hypervisor Vulnerabilities</strong>: The hypervisor itself can become a target for attacks. A vulnerability in the hypervisor can potentially compromise all VMs running on it.<br>- <strong>Complex Security Management</strong>: Implementing and managing security measures across multiple VMs can be challenging and requires diligent oversight.</li></ol><h3>Container Deployment:</h3><p>The container deployment has emerged as a transformative approach, addressing many of the challenges faced in traditional and virtualized environments. Let’s explore how containers provide solutions to these issue.</p><h4>Understanding Containers</h4><p>Containers package an application and its dependencies into a single, lightweight executable unit. Unlike virtual machines (VMs), which include a full operating system (OS), containers share the host OS kernel but run in isolated user spaces. This approach brings numerous benefits and resolves several problems inherent in older deployment methods.</p><h4>Pros</h4><ol><li><strong>Resource Optimization<br>- Lightweight and Efficient</strong>: Containers are much lighter than VMs because they share the host OS kernel. This reduces the overhead and allows for more efficient use of system resources.<br>- <strong>Higher Density</strong>: More containers can be run on a single host compared to VMs, maximizing resource utilization and reducing idle time.</li><li><strong>Scalability<br>- Rapid Scaling</strong>: Containers can be spun up or down quickly, allowing for rapid scaling to meet demand. Orchestration tools like Kubernetes further streamline this process, enabling automated scaling based on real-time needs.<br>- <strong>Microservices Architecture</strong>: Containers are well-suited for microservices, where each service runs in its own container. This modular approach makes scaling individual components easier and more efficient.</li><li><strong>Isolation and Security<br>- Process Isolation</strong>: Containers provide a high level of isolation between processes, reducing the risk that an issue in one container will affect others.<br>- <strong>Improved Security Posture</strong>: While containers share the host OS, they still provide strong isolation. Security features like namespaces and cgroups further enhance isolation, and additional tools can secure the container environment.</li><li><strong>Flexibility and Manageability<br>- Portability</strong>: Containers can run consistently across different environments, from development to testing to production, reducing compatibility issues.<br>- <strong>Simplified Updates</strong>: Updating applications is easier with containers. You can deploy new versions of an application without affecting the rest of the system, and rollbacks are straightforward if issues arise.</li><li><strong>Cost Efficiency<br>- Lower Overheads</strong>: Reduced resource overhead and better utilization translate to cost savings in terms of both hardware and operational expenses.<br>- <strong>Simplified Infrastructure</strong>: Containers reduce the need for complex infrastructure and can run on any system that supports container runtimes, further cutting costs.</li><li><strong>Performance<br>- Minimal Overhead</strong>: Containers have minimal performance overhead compared to VMs, as they don’t require a full guest OS. This leads to better application performance and lower latency.<br>- <strong>Direct Hardware Access</strong>: Containers can access the host’s hardware resources more directly, improving performance for certain applications.</li></ol><h3>Conclusion</h3><p>Container deployment offers a modern solution to many of the challenges faced in traditional and virtualized environments. By providing efficient resource utilization, rapid scalability, strong isolation, and simplified management, containers enhance the agility and performance of IT infrastructure. As organizations continue to adopt and integrate container technologies, they can expect to see significant improvements in efficiency, security, and overall cost-effectiveness.</p><p>Let’s catch up in the upcoming series to gain in-depth knowledge about how Docker works. 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f1494ce38b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pure Vs Impure Functions — Functional Programming]]></title>
            <link>https://kishoremg.medium.com/pure-vs-impure-functions-functional-programming-5ce3beb3c6aa?source=rss-5d89dec82f37------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ce3beb3c6aa</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Kishore M G]]></dc:creator>
            <pubDate>Mon, 25 Mar 2024 04:32:33 GMT</pubDate>
            <atom:updated>2024-03-27T03:53:10.092Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pure Vs Impure Functions — Functional Programming</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*-L3NPL949x8PwD4g_9nBVA.png" /></figure><p>Hey all, curious mind! 🚀 Welcome to the wild, wacky world of Medium — where words dance, ideas collide, and minds mingle like at a cosmic cocktail party! 🎉 So kick off your shoes, grab a metaphorical mojito, and let’s embark on a joyride through the rollercoaster of thoughts. Buckle up, because we’re about to take your brain on a ride it won’t soon forget! 🌟✨</p><p>Here, in this article, let me walk through the definition of pure and impure functions with some examples, and additionally, we’ll explore their advantages. So sit back, relax, and get ready to dive into the fascinating world of function purity! Let’s uncover the magic together! ✨</p><h3>What is Pure function?</h3><p>A pure function is a function which returns same output for a given input. Also, the pure function is completely independent of the environment and external code.</p><p>It always becomes clearer when we look through examples. Let’s bridge theory with real-world applications.</p><p>For instance, consider a function that adds two numbers based on input.</p><pre>function Add(num1: number, num2: number) {<br>  return num1 + num2;<br>}<br><br>console.log(Add(2, 8));   // returns 10<br>console.log(Add(4, 16));  // returns 20</pre><blockquote>In the above code, we can find that when we <strong>pass</strong> <strong>2 and 8 as input</strong> for any number of times, the <strong>output will be 10</strong> which is <strong>predictable</strong>.</blockquote><p>In the above code, there is external factor or state being involved inside the function which could mutate the output. So, this is known as<strong> Pure function</strong>.</p><p>Now, It’s time to explore the other part. Get ready 🚀.</p><h3>What is Impure function?</h3><p>A impure function is just opposite to what pure function means. That is, the function is unpredictable. Either it depends on external code to perform an operation or the output is unpredictable due to the logic built inside the function.</p><p>Here are few defined functions which are impure:</p><ol><li>Math.random()</li><li>Math.getTime()</li></ol><p>So, On each invocation, these functions produce differing results.</p><p>Example always gives us more idea on what it means. Let us take a look on different examples.</p><h4>Example 1:</h4><p>Consider, we have a function that performs an HTTP request.</p><pre>async function fetchDataFromAPI(url: string): Promise&lt;any&gt; {<br>    const response = await fetch(url);<br>    return response.json();<br>}</pre><p>In the above code block, the function <strong>fetchDataFromAPI </strong>is considered as impure as the function doesn’t solely depend on input. It depends on external function and network conditions. Based on that, the result is determined.</p><h4>Example 2:</h4><p>Consider a function that mutate a state of variable outside the code.</p><pre>let value = 0;<br><br>function Adder(num: number) {<br>  value = value + num;<br>}<br><br>Adder(10);                       // value updated to 10<br>Adder(6);                        // value updated to 16<br>console.log(&quot;Result:&quot;, value);   // Result: 16</pre><p>In this case, The function <strong>Adder </strong>mutates the <strong>value </strong>which is defined outside the function.</p><p>This function is considered as impure as it depends on external code.</p><p>Let me explain more with an minor correction on the above code.</p><pre>function Adder(num: number) {<br>  value = value + num;         // value is undefined - Cannot find name &#39;value&#39;<br>}<br><br>Adder(10);                       <br>Adder(6);                        <br>console.log(&quot;Result:&quot;, value); // value is undefined - Cannot find name &#39;value&#39;</pre><p>This is what happens when the value is not found. The function will break if the variable “value” is not defined. Also, the result will differ if the variable “value” is updated by other functions. So, the result is unpredictable.</p><h3>Advantages of Pure function over Impure function:</h3><p>The Pure functions are predictable, maintainable, testable and readable.</p><h4>Predictable/Deterministic</h4><p>Pure functions produce the same output for a given set of input parameters every time they are called.</p><h4>Maintainable</h4><p>The code is maintainable as it doesn’t have any side effects or doesn’t depend on external code/environment.</p><h4>Testable</h4><p>Since pure functions don’t rely on external state or side effects, they can be easily isolated for testing. We can test them in isolation without the need for complex setup or mocking of external dependencies.</p><h4>Readable</h4><p>Pure functions typically have a clear and straightforward purpose. They take input parameters, perform computations, and return a result. This simplicity enhances readability because we can easily understand what the function does without needing to inspect external factors or side effects.</p><blockquote>When we use pure functions, it also helps us to improve performance when we use memoization concept.</blockquote><h3>Should we always go with pure function?</h3><p>While pure functions offer many advantages in terms of predictability, testability, and maintainability, they may not always be the best choice for every situation.</p><p>Here are some use-cases:</p><h4>Use-cases of pure function:</h4><ol><li><strong>Mathematical Computations:</strong> Pure functions are well-suited for mathematical computations where the output depends solely on the input parameters.<br><strong>Example: Squaring a number</strong></li><li><strong>Data Transformation:</strong> Pure functions are commonly used to transform data without modifying the original data.<br><strong>Example: Mapping over array to manipulate the values inside it without changing the original data. (Original data passed as input and modified data is returned)</strong></li></ol><h4>Use-cases of impure function:</h4><ol><li><strong>Logging and Debugging:</strong> Sometimes, we used to wrap the logger function to provide a structured log message</li><li><strong>I/O Operations: </strong>Impure functions are often necessary for performing input/output operations, such as reading from or writing to files, interacting with databases, or making network requests</li></ol><p>As we conclude, remember that understanding these concepts not only empowers us as developers but also opens doors to writing cleaner, more maintainable code. So go forth, armed with newfound knowledge, and may your code always be as pure as the driven snow. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ce3beb3c6aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello World to Golang]]></title>
            <link>https://kishoremg.medium.com/hello-world-to-golang-39f1c3032dd2?source=rss-5d89dec82f37------2</link>
            <guid isPermaLink="false">https://medium.com/p/39f1c3032dd2</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[structure]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Kishore M G]]></dc:creator>
            <pubDate>Sat, 28 Oct 2023 16:15:58 GMT</pubDate>
            <atom:updated>2023-10-28T16:16:15.334Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*fdAjmGxqqqkYKduDYGdfcA.png" /><figcaption>Hello world to Golang</figcaption></figure><p>Today, we will start with basic programming in Golang and see how to build and execute a Golang program.</p><p>Topics to be discussed:</p><ol><li>Go Commands</li><li>Program Structure</li><li>Execution</li></ol><p>For installation, please refer:</p><p><a href="https://go.dev/doc/install">Download and install - The Go Programming Language</a></p><h3>Go Commands:</h3><p>There is a tool called <strong>“Go”</strong> which is used to <strong>manage go source codes</strong> like <strong>building</strong> the go program, <strong>running</strong> the go program, <strong>listing the packages</strong> of<strong> </strong>go, <strong>install</strong> specific package and it can do even more…</p><p>Here is the link to get more knowledge on <a href="https://pkg.go.dev/cmd/go">Go Commands</a>.</p><p>In this blog, we will be discussing two important commands which will be really helpful to compile and run a go program.</p><h4>Build:</h4><p>The command is used to compile and build a program.</p><pre>go build filename.go</pre><p>This command internally compiles the go program and generates an executable file when we execute the program with go build command.</p><p>Generally, it is used in production environment where it builds the program and generates a go binary file and later stores it in the current directory.</p><blockquote>Note: The build command is used to compile executable package. If it is used with reusable package, then it won’t generate any executable file out of it.</blockquote><p>To get more information on packages, refer my blog:</p><p><a href="https://kishoremg.medium.com/packages-in-go-bba20c1cb12f">Packages in Go</a></p><p>Run:<br>This command does the job of go build and also does one more job in addition to it.</p><pre>go run filename.go</pre><p>You can easily find it from the name of the command itself.</p><p>Did you find the answer?</p><p>Great! You found it….</p><p>This command again <strong>builds</strong> the program and <strong>executes</strong> the program as soon as the compilation is done.</p><p><strong>Usage:</strong></p><p>This command is used to run a program locally and won’t be used in the production environment as it stores the executable file in a temporary directory.</p><blockquote>Note: The run command is used to build and run the executable package. If it is used with reusable package, then it will return an error stating “package command-line-arguments is not a main package”.</blockquote><h3>Program Structure:</h3><p>The structure of the go executable program is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*W8D0e2DsFkbazLh2hSo3zw.png" /><figcaption>Go basic program structure</figcaption></figure><p>We can split the program structure into three parts:</p><ol><li>Package name</li><li>Imports</li><li>Functions</li></ol><p><strong>Package name:<br></strong>This is where we define the <strong>name of our package</strong> in the program. As we are starting with a basic go program, we proceed with single go file and that too is an executable package, so we define the package name as main.</p><blockquote>Note: All the executable package name will have the package name as main.</blockquote><p><strong>Imports:<br></strong>The section is responsible for <strong>importing package</strong>s used in our program. If we want to use any standard library like math, fmt… Then we need to <strong>import it first</strong> and then use it by <strong>referencing</strong> the package name.</p><p>In the above example, we have imported the package called fmt which helps us to format Input and Output.</p><p>For multiple imports, we follow a slightly different syntax where the imports will be wrapped with brackets:</p><pre>package main<br><br>import (<br>  &quot;fmt&quot;<br>  &quot;math&quot;<br>)<br><br>func main(){<br>  // body<br>}</pre><p><strong>Functions:<br></strong>Here, we define the main function and generally a function is defined with the following structure</p><pre>func functionName(input1 variableType, input2 variableType) (returnType1, returnType2) {<br>  // Body<br>}</pre><p><strong>func</strong> is a keyword used to define a function.</p><p><strong>functionName</strong> is the name of the function that tell what does this function do. This function name is user specific.</p><p><strong>Input Parameter: </strong>We define the input parameters with its type. input1 is the variable name and variableType is the value type of the variable.<br>And the input parameters are separated by commas and wrapped with brackets.</p><p><strong>Return: </strong>Here we define the type of return value that the function returns. <br>Say if there is an addition function which returns a value of type integer, then the return type is set as integer.</p><h3>Execution:</h3><p>To execute a program, we basically use two commands for two different use cases.</p><h4>To build and execute a generated binary file as we do in production environment.</h4><p><strong>Step 1:</strong></p><p>Assume we have a go file with filename as <strong>test.go</strong></p><pre>go build test.go</pre><p>When we execute this command, it generates an executable file with same filename.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*zVBLZuZ4kpfbmo0xPx4_Nw.png" /><figcaption>project structure</figcaption></figure><p><strong>Step 2:</strong></p><p>To run this executable file in Mac, we run this command which executes the program.</p><pre>Command:<br>./test<br><br>Output:<br>Hello world!!!</pre><h4>To run a go program directly as we do in local environment:</h4><p>To run a go program directly, we use the <strong>go run test.go</strong> command. It builds and executes the file directly.</p><pre>Command:<br>go run test.go<br><br>Output:<br>Hello world!!!</pre><p>Welcome to the vibrant world of Golang, where ‘Hello, World!’ is just the beginning of an incredible journey into the realms of powerful, efficient, and elegant programming. May your code always compile, your functions be optimized, and your passion for learning never cease.</p><p>Happy coding in Golang!”</p><blockquote>“Live as if you were to die tomorrow. Learn as if you were to live forever.” — Mahatma Gandhi</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39f1c3032dd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Packages in Go]]></title>
            <link>https://kishoremg.medium.com/packages-in-go-bba20c1cb12f?source=rss-5d89dec82f37------2</link>
            <guid isPermaLink="false">https://medium.com/p/bba20c1cb12f</guid>
            <category><![CDATA[encapsulation]]></category>
            <category><![CDATA[modules]]></category>
            <category><![CDATA[go-packages]]></category>
            <category><![CDATA[package]]></category>
            <category><![CDATA[executable]]></category>
            <dc:creator><![CDATA[Kishore M G]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 18:28:01 GMT</pubDate>
            <atom:updated>2023-10-25T18:42:11.963Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi there 👋, Welcome back. In this blog, I am going to share a main concept used in Go which stands as a main pillar to Golang.</p><h3>What is a package?</h3><p>A package is a <strong>container</strong> that <strong>holds go source files</strong> which is used to <strong>perform</strong> some <strong>specific task</strong>. In simple words, A package is a folder that contains multiple functions which is used to perform some intended operations like a <strong>add()</strong> function that returns <strong>sum of two numbers</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*iJUn2ALJlRWGtBbebx2PnA.jpeg" /><figcaption>Packages in Golang</figcaption></figure><h4>Let me explain the concept of package with an example:</h4><p>Consider, a basic package <strong>“math”</strong> in golang. The <strong>“math”</strong> package contains multiple functions which performs specific operations.</p><p>Few functions defined in <strong>“math”</strong> package are</p><ul><li><a href="https://pkg.go.dev/math#Sqrt">func Sqrt(x float64) float64</a></li><li><a href="https://pkg.go.dev/math#Abs">func Abs(x float64) float64</a></li><li><a href="https://pkg.go.dev/math#Acos">func Acos(x float64) float64</a></li><li><a href="https://pkg.go.dev/math#Acosh">func Acosh(x float64) float64</a></li><li><a href="https://pkg.go.dev/math#Asin">func Asin(x float64) float64</a></li><li><a href="https://pkg.go.dev/math#Asinh">func Asinh(x float64) float64</a></li><li><a href="https://pkg.go.dev/math#Atan">func Atan(x float64) float64</a></li><li><a href="https://pkg.go.dev/math#Atan2">func Atan2(y, x float64) float64</a></li><li>…….</li></ul><p>For more reference on <strong>“math”</strong> package, please do refer:</p><p><a href="https://pkg.go.dev/math">math</a></p><p>This <a href="https://pkg.go.dev/math#Sqrt"><strong>Sqrt()</strong></a> function helps us to perform math operation that returns square root of the input given as a parameter.</p><pre>package main</pre><pre>import (<br> &quot;fmt&quot;<br> &quot;math&quot;<br>)</pre><pre>func main() {<br> input := 5<br> <br> result := math.Sqrt(input*input)<br> <br> fmt.Printf(&quot;%.1f&quot;, result)<br>}</pre><p><strong>Output:</strong></p><pre>5.0</pre><h3>Importance of packages:</h3><ol><li>Code Reusability:<br><strong> — </strong>Use of packages improves code reusability. <br> — Assume, the <strong>sqrt()</strong> function which we discussed earlier, returns the square root of input value. <br> — So, Instead of writing the code from scratch for these operations which again increases the time and code replication, we combine all these function in a package and import it whenever we require. This improves the code reusability and also save the time of developers.</li><li>Organization:<br> — Packages helps us to <strong>organize </strong>our<strong> codebase</strong>. This improves our <strong>codebase structure</strong> and make our code look <strong>neat and clean</strong>. <br> — Also, it helps to <strong>group related codes</strong> and combine those codes in a <strong>separate package</strong> which can <strong>used</strong> in our <strong>codebase</strong> at <strong>different places</strong>.</li><li>Standard Library:<br> — The standard library is a <strong>collection of wide range of functions</strong> which are <strong>well tested</strong> and provides functional usage in multiple areas. Let me tell you few areas that are covered by standard library: I/O, cryptography, http,…</li><li>Encapsulation:<br> — In golang, we used to <strong>export variables, functions</strong> using <strong>naming</strong> <strong>conventions</strong>. <br> — When a variable name starts with an <strong>uppercase</strong> letter, then the variable/function is being <strong>exported</strong>. When a variable name starts with <strong>lowercase</strong> letter, then this <strong>restricts</strong> the variable/function from <strong>being</strong> <strong>exported</strong>. <br> — This<strong> avoids interferences within packages</strong> and other packages can only use the exported variables or functions.</li></ol><h3>Types of packages:</h3><ol><li>Executable package</li><li>Reusable package</li></ol><h4>Executable package:</h4><p>The package that we build and compile it into an executable program is called as Executable package. When a package is made as executable, it means that the program execution or Go application starts from this package.</p><p><strong>Example:</strong></p><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>func main() {<br>    fmt.Println(&quot;Hello, World!&quot;)<br>}</pre><p><strong>How to make a package as Executable?</strong><br>To make a package executable, two things need to done:</p><ol><li>Declare the <strong>package name as main</strong> in order to make the package as Executable.</li><li>The <strong>package</strong> <strong>must</strong> <strong>contain func main()</strong> because the <strong>main()</strong> function is an <strong>entry point</strong> for an executable package. When a program is made to run, the entry point for that program will be main() function.</li></ol><p><strong>How to run the Executable package?<br></strong>Once the package is build and compiled, a <strong>binary compiled file</strong> will be <strong>generated</strong>. On the <strong>execution of that compiled binary file</strong>, the <strong>program</strong> starts to <strong>run</strong>.</p><h4>Reusable package:</h4><p><strong>Reusable package</strong> is <strong>designed</strong> to <strong>perform</strong> some specific <strong>task</strong> which can be <strong>used</strong> in <strong>other packages</strong> instead of running the package itself. On building this package, <strong>no executable file</strong> will be <strong>generated</strong>. This mainly serves the purpose of reusability. All the standard library are referred as Reusable package.</p><p><strong>Example:</strong></p><pre>// Reusable package<br>package mylogic</pre><pre>import &quot;fmt&quot;</pre><pre>func Add(a int, b int) int {<br>    return a + b<br>}</pre><pre>func Subtract(a int, b int) int {<br>    return a - b<br>}</pre><pre>// Executable package which uses reusable package.<br>package main</pre><pre>import (<br>  &quot;fmt&quot;<br>  &quot;mylogic&quot;<br>)</pre><pre>func main() {<br>  a := 10<br>  b := 5<br>  <br>  resultAdd := mylogic.Add(a,b)<br>  fmt.Println(&quot;Addition result:&quot;, resultAdd)<br> <br>  resultSub := mylogic.Subtract(a,b)<br>  fmt.Println(&quot;Subtraction result:&quot;, resultSub)<br>}</pre><p><strong>Output:</strong></p><pre>Addition result: 15<br>Subtraction result: 5</pre><p>Goodbye, and thank you for reading! Hope, the information is useful. If you have more questions in the future, please feel free to add your questions in the comment section. Have a great day😃 !</p><p>Quote #2:</p><blockquote>Learning never exhausts the mind. — Leonardo da Vinci</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bba20c1cb12f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Golang]]></title>
            <link>https://kishoremg.medium.com/introduction-to-golang-4dc3c279ff88?source=rss-5d89dec82f37------2</link>
            <guid isPermaLink="false">https://medium.com/p/4dc3c279ff88</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Kishore M G]]></dc:creator>
            <pubDate>Sat, 21 Oct 2023 16:19:42 GMT</pubDate>
            <atom:updated>2024-05-08T02:51:31.356Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello 👋 and welcome, everyone, to my very first blog. I’m embarking on a new adventure 🏃 in the world of blogging.</p><p>So, I am gonna make you explore these topics with 3W.</p><ol><li>What</li><li>Why</li><li>Where</li></ol><h3>What is Golang?</h3><p>A programming language <strong>developed and designed</strong> by the team “<strong>Google</strong>”. The team includes <a href="https://en.wikipedia.org/wiki/Robert_Griesemer"><strong>Robert Griesemer</strong></a><strong>, </strong><a href="https://en.wikipedia.org/wiki/Rob_Pike"><strong>Rob Pike</strong></a><strong>, and </strong><a href="https://en.wikipedia.org/wiki/Ken_Thompson"><strong>Ken Thompson</strong></a>. The language is either know as “Go” or “Golang”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*DI6qfE1Ahdw9Vz-np7Ubjg.png" /><figcaption>Go language</figcaption></figure><p>The <strong>Golang</strong> is a <strong>statically typed language</strong>. The syntax will more or like be similar to C.</p><p>Let me explain what is <strong>statically typed</strong>.</p><h4><strong>Statically typed</strong></h4><p>It is a way in which the <strong>type checking</strong> occurs at the <strong>compile time</strong> rather than at run time.</p><blockquote><em>At the time of </em><strong><em>compilation</em></strong><em>, the </em><strong><em>source code </em></strong><em>is </em><strong><em>converted</em></strong><em> to</em><strong><em> machine readable format</em></strong><em>. So, even before the compile time, all the variables should be defined with a type or in simple words, the type of the variable should be know.</em></blockquote><p>Say for example, Consider a simple addition program. Here, the variables “a” and “b” are defined even before compilation.</p><pre>package main<br><br>import &quot;fmt&quot;<br><br>func main() {<br>  // The variable &#39;a&#39; and &#39;b&#39; is defined before the compile time.<br>  var a int <br>  var b int<br>  a = 5<br>  b = 6<br>  <br>  fmt.Println(a+b)<br>}</pre><p>Few other statically typed languages are C, C++, Java, Swift……</p><p>Other languages like Javascript, Ruby, Php are dynamically typed languages where the type checking occurs at the run-time. Let us not deviate from the actual topic.</p><blockquote>For more information, please refer: <a href="https://en.wikipedia.org/wiki/Type_system">https://en.wikipedia.org/wiki/Type_system</a></blockquote><h3>Why is Golang a popular choice?</h3><p>Golang has gained popularity in many areas.</p><ol><li><strong>Simplicity and Readability</strong><br>The minimalistic syntax format makes us easy to read and write a program. Due to this, we get a maintainable and a bug free software.</li><li><strong>Efficiency<br>Go </strong>guarantees speed and efficiency. It uses the system resource in a more efficient way. The language offers low-level access and better garbage collection.</li><li><strong>Concurrency<br></strong>It helps us to run concurrent threads that is we can make use of multi processor core to run programs parallelly. Say, we have a main program and we wanted to create a thread and run a different program. At this time, the main program is independent and get unaffected even if the program running in thread is affected.</li><li><strong>Standard Library<br></strong>The Golang provides multiple standard library which includes packages like encoder, decoder, HTTP packages, packages related to databases and even more.</li><li><strong>Strong Typing<br></strong>As all the type errors are caught at compile time, it helps us to build a more reliable software.</li><li><strong>Cross-Platform<br></strong>In Golang, we can write a code in one language and compile and run the program in other platforms like linux, macOS and windows.</li><li><strong>Open Source<br></strong>This language is aa open source software which has a broader and growing community due to which it stays up-to-date.</li><li><strong>Scalability<br></strong>The Golang is well suited for building scalable applications like networking and web services.</li><li><strong>Safety and Reliability<br></strong>This language enforces us to use good programming practices. It also has strong community support for security best practices.</li><li><strong>Finally, Google’s Backing<br></strong>As the golang is developed and supported by google, it gives us more credibility to its design and use. Also, Most of google projects are developed using Golang.</li></ol><h3>Where is Golang used?</h3><p>The Golang is used to develop multiple domain softwares like cloud based applications, web services, networking applications and even more…..</p><p>Some of the top companies using Golang are</p><ol><li>Google</li><li>Uber</li><li>Dropbox</li><li>IBM</li><li>Cloudflare</li><li>Paypal</li><li>Netflix</li></ol><p>As mentioned earlier, I’m embarking on a new journey into the world of blogging. With this, I’ve reached the conclusion of my first blog, and it’s time to sign off. I look forward to reconnecting with you in my next post, where we’ll explore exciting new topics together.</p><p>As I wanted to end all my blog with a quote, I am starting it right here:</p><blockquote>“The journey of a thousand miles starts with a single step” — Laozi</blockquote><p>Next → <a href="https://kishoremg.medium.com/packages-in-go-bba20c1cb12f">Packages in Golang</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4dc3c279ff88" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>