Wednesday, June 29, 2022

GO's Concurrency - 1






 

We all know that GO is famous for "goroutines". They are one of the basic and important unit in GO. That's why it is very important to understand about goroutine and How they works.

When the GO process begins, by default it has at least one goroutine. You are not creating this default goroutine, it is by default gets created when you write main function. YES this default goroutine is nothing but main goroutine

Without spending much time, lets create our first simple go routine.

func main() {

    //Write some logic here

    go simpleGoRoutine()

    //continue with remaining code logic here
}

func simpleGoRoutine() {
    fmt.Println("I am running concurrently")
}

 You can simply place go keyword before function.

Lets look at other ways to create goroutines. We can also use anonymous functions.

func main() {

    //Write some logic here

    go func () {
        fmt.Println("I am running concurrently")
    } ();

    //continue with remaining code logic here
}

You can also assign function to variable and place go before variable.

func main() {

    //Write some logic here

    anotherway := func() {
        fmt.Println("I am running concurrently")
    }

    go anotherway()
   
    //continue with remaining code logic here
}

This is how we can use goroutine in GO and run code concurrently.

Lets dive bit more deeper into goroutines. What is actually goroutine. Is it thread or something else 😏

Wait internals are coming soon !!!

 



 

 

Tuesday, June 28, 2022

My Favourite IDE for GO Lang


So far we have finish with 

Introduction to GO 
GO Installation on Windows

Let's talk about the IDE in this blog. IDE plays a very important role during our day to day development activity.

Now a days GOlang is supported by most of the popular editors Following is the list of few popular IDES

  • VS Code 
  • GOLand
  • LiteIDE
  • Atom

If you ask me VS Code & GOLand are my favorite IDEs for GOlang.

In this post I will talk about VS Code IDE.

Installing VS Code

There are lots of videos on YOUTUBE & articles on this. Here is link to one of such article. (link)
 

GO in VS Code 

I like VS Code because it is free 😁. As a new learner everyone is looking for free stuff. Jokes apart.
VS Code is basically opensource IDE which is easily available on Windows & Linux Platform. Another reason I like VS Code is because it is made by Microsoft. ( Their software are very User Friendly)

Microsoft has release the source code on GitHub under MIT License.

You can use the GO Extension for VS Code, you will get IntelliSense, Search, Debugging, code navigation etc.. by default. You can Install this Extension from the VS Code MarketPlace

 Watch "Getting Started" video

 You can explore more features about the VS Code on the official site documentation.

 Once you are done with VS Code Installation & GO Extension. You can begin your GOlang journey

Enjoy.

Soon will come up with some interesting GO blogs.