<?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 Chandan Kumar on Medium]]></title>
        <description><![CDATA[Stories by Chandan Kumar on Medium]]></description>
        <link>https://medium.com/@chandankumar_64074?source=rss-8854dc5893c0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*EycLCkY0zcW9LaX2hZg68Q.png</url>
            <title>Stories by Chandan Kumar on Medium</title>
            <link>https://medium.com/@chandankumar_64074?source=rss-8854dc5893c0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 14:41:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chandankumar_64074/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[Docker remove all docker container and images]]></title>
            <link>https://medium.com/@chandankumar_64074/docker-remove-all-docker-container-and-images-4f2bd08f5461?source=rss-8854dc5893c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f2bd08f5461</guid>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Chandan Kumar]]></dc:creator>
            <pubDate>Thu, 07 May 2020 09:29:29 GMT</pubDate>
            <atom:updated>2020-05-07T09:29:29.306Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sFlKT6saYqtNeo_ZHavgVA.png" /></figure><p><strong>How do we clean up all the docker containers and images?</strong></p><h4>List all the the container ID’s.</h4><pre>docker ps -aq</pre><blockquote>Output: It return all the container Id’s</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*XLvOx6onOzg4Ui0md50tKA.png" /></figure><h4>Before removing, need to stop all the containers.</h4><pre>docker stop $(docker ps -aq)</pre><blockquote>Output: It return all the stoped container id’s.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*dHHD_5NBMKatYpy30BpyRQ.png" /></figure><h4>Remove all the containers</h4><pre>docker rm $(docker ps -aq)</pre><p>If your container is not stop it throw error, otherwise it remove all the container’s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vrPmxsCaVyFP6FDSp_0vQw.png" /></figure><pre>Error response from daemon: You cannot remove a running container CONTAINER_ID. Stop the container before attempting removal or force remove</pre><p><strong>Remove all the images</strong></p><pre>docker rmi $(docker images -q)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1kdh1f3jyUua7CGqeMDT0Q.png" /></figure><p>If image is not using on running container, then it delete otherwise, it throw given below error.</p><pre>Error response from daemon: conflict: unable to delete 72a2549d1717 (cannot be forced) - image is being used by running container bdbf0798facc</pre><p><strong>Note</strong>: <em>Before deleting images, need to stop and remove the container.</em></p><p><em>Thanks for reading …</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f2bd08f5461" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless with Google Cloud Function and GoLang]]></title>
            <link>https://medium.com/@chandankumar_64074/serverless-with-google-cloud-function-and-golang-a6e19f496896?source=rss-8854dc5893c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6e19f496896</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Chandan Kumar]]></dc:creator>
            <pubDate>Wed, 06 May 2020 19:31:21 GMT</pubDate>
            <atom:updated>2020-05-06T19:50:31.288Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*InsyugVGvrNdawrWjNjkDA.png" /></figure><h3><strong>What is serverless?</strong></h3><p>Serverless computing is a cloud computing execution model in which the cloud provider runs the server, and dynamically manages the allocation of machine resources. Pricing is based on the actual amount of resources consumed by an application, rather than on pre-purchased units of capacity.</p><p><strong>What is Cloud Function?</strong></p><p>Google <strong>Cloud Functions</strong> is a serverless execution environment for building and connecting <strong>cloud</strong> services. With <strong>Cloud Functions</strong> you write simple, single-purpose <strong>functions</strong> that are attached to events emitted from your <strong>cloud</strong> infrastructure and services. Your <strong>function</strong> is triggered when an event being watched is fired.</p><p><strong>What is GoLang?</strong></p><p>Go is a statically typed, compiled programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. Go is syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style concurrency.</p><h4>“Step by step guide for setup project using serverlesss”</h4><ol><li>Installation <strong>serverless</strong> using <strong>npm</strong> library. If you don’t have npm library in you operating system, please go through this URL to install Node and NPM: <a href="https://www.taniarascia.com/how-to-install-and-use-node-js-and-npm-mac-and-windows/">https://www.taniarascia.com/how-to-install-and-use-node-js-and-npm-mac-and-windows/</a></li></ol><pre><strong>npm install -g serverless</strong></pre><p>2. Setup your project:</p><ul><li>For creating Node js skeleton project.</li></ul><pre>serverless create — template <strong>google-nodejs</strong> — path my-service</pre><ul><li>For creating Python skeleton project.</li></ul><pre>serverless create --template <strong>google-python</strong> --path my-service</pre><ul><li>For creating GoLang skeleton project.</li></ul><pre>serverless create --template <strong>google-go</strong> --path my-service</pre><ul><li>Once you run the serverless command for GoLang.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DkZpqO2wRqGRMfVv.png" /></figure><blockquote><em>Before doing anything, enable Debugger to watch process log.</em></blockquote><ul><li>It work for all the Unix OS (Mac)</li></ul><pre>export SLS_DEBUG=*</pre><ul><li>For windows operating system</li></ul><pre>SET SLS_DEBUG=*</pre><blockquote><strong><em>Let’s understand Serverless configuration deeply</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EgE69i9FAoWyjfPg.png" /></figure><blockquote><em>Function code </em><strong><em>fn.go</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AMXIJ97KVEgsxwXC.png" /></figure><blockquote><strong><em>How to run given two function locally?</em></strong></blockquote><ul><li>For running event http.</li></ul><pre>serverless invoke local -s {stage} -f {function_name} --data &#39;{ &quot;queryStringParameters&quot;: {&quot;id&quot;:&quot;123&quot;}}&#39;</pre><ul><li>For running event gcp bucket.</li></ul><pre>serverless invoke local -s {stage} -f {function_name} --path bucket_event_mock.json</pre><blockquote><strong><em>How to deploy on google cloud function?</em></strong></blockquote><pre>serverless deploy -s {development|staging|production}</pre><blockquote><strong><em>For removing serverless function</em></strong></blockquote><pre>serverless remove -s {development|staging|production}</pre><p>GitHub Link :: <a href="https://github.com/chandan4u/medium-serverless-golang/tree/master/my-service">https://github.com/chandan4u/medium-serverless-golang/tree/master/my-service</a></p><blockquote><em>Next topic :: How to encrypt/decrypt secrets and use inside serverless project.</em></blockquote><p><em>Thanks for reading …</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6e19f496896" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go Lang — Best practices to design micro-service and common errors]]></title>
            <link>https://medium.com/@chandankumar_64074/go-lang-best-practices-to-design-micro-service-and-common-errors-6524fb9d9ec5?source=rss-8854dc5893c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6524fb9d9ec5</guid>
            <dc:creator><![CDATA[Chandan Kumar]]></dc:creator>
            <pubDate>Wed, 06 May 2020 19:19:57 GMT</pubDate>
            <atom:updated>2020-05-06T19:19:57.054Z</atom:updated>
            <content:encoded><![CDATA[<h3>Go Go and GoLang</h3><p>Go Lang — Best practices and common errors</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*30aoNxlSnaYrLhBT0O1lzw.png" /></figure><ol><li><strong>Function Adapter -&gt; right way to error handling</strong></li></ol><p>Not preferrer way of handling error</p><pre>func init() {<br>    http.HandleFunc(&quot;/&quot;, handler)<br>}<br><br>func handler(w http.ResponseWriter, r *http.Request) {<br>    err := doThis()<br>    if err != nil {<br>        http.Error(w, err.Error(), http.StatusInternalServerError)<br>        log.Printf(&quot;handling %q: %v&quot;, r.RequestURI, err)<br>        return<br>    }<br><br>    err = doThat()<br>    if err != nil {<br>        http.Error(w, err.Error(), http.StatusInternalServerError)<br>        log.Printf(&quot;handling %q: %v&quot;, r.RequestURI, err)<br>        return<br>    }<br>}</pre><p>Preferred way of handling error</p><pre>func init() {<br>    http.HandleFunc(&quot;/&quot;, errorHandler(betterHandler))<br>}<br><br>func errorHandler(f func(http.ResponseWriter, *http.Request) error) http.HandlerFunc {<br>    return func(w http.ResponseWriter, r *http.Request) {<br>        err := f(w, r)<br>        if err != nil {<br>            http.Error(w, err.Error(), http.StatusInternalServerError)<br>            log.Printf(&quot;handling %q: %v&quot;, r.RequestURI, err)<br>        }<br>    }<br>}<br><br>func betterHandler(w http.ResponseWriter, r *http.Request) error {<br>    if err := doThis(); err != nil {<br>        return fmt.Errorf(&quot;doing this: %v&quot;, err)<br>    }<br><br>    if err := doThat(); err != nil {<br>        return fmt.Errorf(&quot;doing that: %v&quot;, err)<br>    }<br>    return nil<br>}</pre><p><strong>2. Avoid nesting by error handling</strong></p><p>Not preferred way</p><pre>type Gopher struct {<br>    Name     string<br>    AgeYears int<br>}</pre><pre>func (g *Gopher) WriteTo(w io.Writer) (size int64, err error) {<br>    err = binary.Write(w, binary.LittleEndian, int32(len(g.Name)))<br>    if err == nil {<br>        size += 4<br>        var n int<br>        n, err = w.Write([]byte(g.Name))<br>        size += int64(n)<br>        if err == nil {<br>            err = binary.Write(w, binary.LittleEndian, int64(g.AgeYears))<br>            if err == nil {<br>                size += 4<br>            }<br>            return<br>        }<br>        return<br>    }<br>    return<br>}</pre><p>Preferred way -&gt; Less nesting means less cognitive load on the reader</p><pre>func (g *Gopher) WriteTo(w io.Writer) (size int64, err error) {<br>    err = binary.Write(w, binary.LittleEndian, int32(len(g.Name)))<br>    if err != nil {<br>        return<br>    }<br>    size += 4<br>    n, err := w.Write([]byte(g.Name))<br>    size += int64(n)<br>    if err != nil {<br>        return<br>    }<br>    err = binary.Write(w, binary.LittleEndian, int64(g.AgeYears))<br>    if err == nil {<br>        size += 4<br>    }<br>    return<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6524fb9d9ec5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>