<?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 Vijeth Ag on Medium]]></title>
        <description><![CDATA[Stories by Vijeth Ag on Medium]]></description>
        <link>https://medium.com/@vijethag?source=rss-9dc3be00e1ee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9KtRcWBqohAIbrE-.</url>
            <title>Stories by Vijeth Ag on Medium</title>
            <link>https://medium.com/@vijethag?source=rss-9dc3be00e1ee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:42:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vijethag/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[GoLang testing and TDD, quick guide]]></title>
            <link>https://medium.com/@vijethag/golang-testing-and-tdd-quick-guide-8f59ebfdb94f?source=rss-9dc3be00e1ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f59ebfdb94f</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Vijeth Ag]]></dc:creator>
            <pubDate>Thu, 06 Oct 2022 13:53:38 GMT</pubDate>
            <atom:updated>2022-10-06T13:53:38.687Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, In this article I want share a quick intro to Testing in GO and TDD</p><h3>TDD:</h3><p>The idea of TDD is to first write a test case so that it fails, then write only as much as code to make this test pass. and repeat this cycle with refactor</p><blockquote>Personally I think this helps by giving space to think more of all possible cases of the actual code is going to be, and here Tests are like code about code.<br>“Meta code”. You describe the code first and then write the actual code</blockquote><p>Go has built-in testing package called “testing” imported using</p><blockquote><em>import “testing”</em></blockquote><h3><strong>GoLang testing Setup:</strong></h3><ul><li>Test files need to have _test.go as suffix, so that when tests are run Go will know all the test files to run. for example test file main.go would be main_test.go</li><li>Inside test files we can specify functions to test using the format Test&lt;FunctionName&gt; for example if we are testing a function called Addition(), then the Test function name would be TestAddition()</li></ul><h3>Running the tests:</h3><ul><li>Tests can be simply run using “go test” command which runs all _test.go files and prints pass/fail with time taken. If any fails prints the name of test.</li><li>“go test -v” v for verbose, will run test with more detailed output, lists all test names and time taken individually</li><li>We cab also run only a specific, required test case(function) using -run flag. For example “go test -run=TestMultiplication” would run only Test function TestMultiplication, and not the whole _test.go file</li><li>Test coverage:<br> To display test case coverage we can run “go test -cover” this will run. test and prints coverage in percentage</li><li>cover flag has more option such as exporting as html etc.</li></ul><p>Please check below GitHub repo for demo project along with Github Actions setup.</p><p><a href="https://github.com/vijeth-ag/go-lang--testing">https://github.com/vijeth-ag/go-lang--testing</a></p><p>The GH actions on every push will run “go test -cover” and send a mail about test coverage.<br>(mail configs set in Github-repo&gt;Settings&gt;Secrets)</p><p>Reading materials used:</p><p><a href="https://brainhub.eu/library/test-driven-development-tdd">Test-Driven Development (TDD) - Quick Guide [2025]</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f59ebfdb94f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang-Javascript: In-progress http request cancellation]]></title>
            <link>https://medium.com/@vijethag/golang-javascript-in-progress-http-request-cancellation-9cf296555453?source=rss-9dc3be00e1ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cf296555453</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Vijeth Ag]]></dc:creator>
            <pubDate>Tue, 16 Aug 2022 14:18:09 GMT</pubDate>
            <atom:updated>2022-08-16T14:18:09.778Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello,</p><p>Suppose we are creating a Go server with an endpoint which could take a while to process, which may spawn couple of Goroutines and this request may possibly be cancelled by client/user while it is processing,</p><p>In this case It would be nice to provide an option for Goroutines to stop processing.</p><p>For example we are running a Movie Ticket booking API and user can search for ticket availability, and there could be chances the user may close the browser, click cancel, or connection may drop off etc.</p><p>In this scenario it is best to stop the work being done by Goroutines, so that the resources are released — this is a code optimisation.</p><p>How this can be done?</p><p>Using http request.Context() and Channel.<br>The Golang in its request Context has a <strong>Done channel</strong> which receives empty struct in case of current http request gets closed/cancelled for whatever reasons.</p><p>We can, using select statement listen to this channel <strong>&lt;-ctx.Done()</strong> for any such events on the context, do a <strong>return</strong> to stop any goroutine’s work.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a67e68270b9af2bc44a3d9457bf0a74e/href">https://medium.com/media/a67e68270b9af2bc44a3d9457bf0a74e/href</a></iframe><p>Client side:<br>From Javascript to be able to give an option for user to cancel a http request, we can use <a href="https://developer.mozilla.org/en-US/docs/Web/API/AbortController">AbortController</a>. We can also close tab/window, which has the same effect on Go endpoint.</p><p>Please find demo code below, Check readme for running instructions</p><p><a href="https://github.com/vijeth-ag/go-lang--http-request-cancellation">https://github.com/vijeth-ag/go-lang--http-request-cancellation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cf296555453" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>