Introduction to Golang

  1. Faster execution: Golang is a compiled language. It doesn’t require any interpreter, leading to faster development. The boosted back-end speed of Golang helps in quicker execution.
  2. Scalable: Golang offers excellent scope for scalability. Multiple functionalities can run at the same time, and it is easy to extend them to existing applications when necessary. Not only is the language itself inherently performant, but it also strengthens collaboration, readability, and maintenance.
  3. Effective garbage collection: Garbage collectors play an essential role in memory management. They are responsible for tracking heap memory allocation and freeing up unused memory while keeping the allocations that are still in use. Golang uses a non-generational concurrent tri-color mark & sweep collector. The Go scheduler is responsible for scheduling the application and garbage collector. Developers need not worry about the allocation and deallocation of memory.
  4. Concurrency: The key feature provided by Golang is its concurrency. Because of the concurrency approach of Golang, developers can achieve efficiency, faster execution, scalability, and manageable performance of applications. Go has introduced Goroutines — a lightweight entity to efficiently perform concurrency. Goroutines need significantly less memory to initialize and can grow & shrink depending on requirements. Also, through the channels, multiple goroutines can easily communicate with each other.
  5. Dependency management: A critical job of programmers is handling the dependency of the application. Golang has a built-in package management system. This eliminates the requirement of a third-party package & dependency management system. Go 1.11 and Go 1.12 has given support for Go Modules, which manages the dependent packages in the application.
  6. Active developer community: Golang is an open-source language. Currently, over 1 million developers are actively programming with Golang. Having an active and strong developer community means that support will always be available for any issues faced during the development process.
  • Interfaces
  • Functions
  • Methods
  • Struct
  • Slices
  • Maps
  1. Package declaration: Just as in other languages like exp. Java, where we need to define the package name first, Golang also needs to start with the declaration of the package name. <packagename>
    So, only two values can be possible for the package name string. One is the main or the name of the directory it is in.
    Package main tells the Go compiler to create an executable file.
  2. Import packages: To import required packages in the current program, we need to import that package first. To use the data members from other packages, we need to import that package first. Following are the two ways to import package names:
    import “fmt”
    If we want to import multiple packages, we can do it this way:
    import “fmt”
    import “strings”
    The best way of importing is:
    import (
    “fmt”
    “strings”
    )
  3. Starting point — function main(): In Golang, the main package is a special package used with the executable programs. This package contains main() function. The main() function is a special type of function and is the entry point of the executable programs. It does not take any argument nor return anything. Go automatically calls the main() function; thus, there is no need to call the main() function explicitly. Every executable program must contain a single main package and a main() function.
  4. Variables: A Variable is the name given to a memory location to store a value of a specific type
    There are multiple ways to declare variables in Golang, such as…read more.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Opcito Technologies

Opcito Technologies

170 Followers

Product engineering experts specializing in DevOps, Containers, Cloud, Automation, Blockchain, Test Engineering, & Open Source Tech