In this post we will understand what is Golang and what are its features and differences from other programming languages.We will understand how can install and setup Golang in our system .
What is Golang
Golang is a programming language created at Google. It is a statically typed, compiled language with syntax similar to that of C, but with additional features and a more modern in terms of overall design.
One of the primary goals of the Go project was to create a language that would be easy to learn for programmers already familiar with C-like languages, but with enough differences to make it a worthwhile endeavour for experienced programmers to learn something new.
In general, Go is more concise and expressive than C, while still maintaining a strong focus on simplicity and readability. One of the most unique features of Go is its focus on concurrent programming.
Unlike most other languages, which require the use of special libraries or frameworks to write concurrent code, Go has built-in support for concurrent execution of code across multiple cores. This makes it much easier to write code that can take advantage of today’s multicore processors. If you’re interested in learning more about Go, there are a number of excellent resources available, including a free online book called “The Go Programming Language” by Alan Donovan and Brian Kernighan (the authors of the C programming language book).
Difference Between Java and Golang
|Golang is a procedural language. This means that code is organized into procedures, and data is manipulated through these procedures.
|Java is a class-based, object-oriented language
|Golang is a dynamically typed language. This means that variables can be declared without a specific data type, and the type can be changed at runtime
|Java is a statically typed language. This means that variables must be declared with a specific data type, and that type cannot be changed
|Golang code is compiled into native code. This code can be run on any platform that supports the Go runtime .
|Java code is compiled into bytecode. This bytecode is platform independent and we can run on any platform that has a Java Virtual Machine(JVM)
|Golang doesn’t have Garbage Collector and memory has to be freed up manually
|Java has Garbage collector and memory can be automatically freed up
How to Install Golang
There are variety of Ways to Install Golang in your system . You can choose the one which suits you the best . There are primarily three ways to install and setup Golang .
1. Installing Golang In Mac
To install Golang on Mac, you will need to have XCode Command Line Tools installed. This can be done by opening the Terminal app, and then running the following command:
$ brew update && brew doctor
Once you’re done with this step, go back to Terminal and run another command (which should now be installed).
$ brew install go1.10-darwin/x86_64
This will download and install Go 1.10 for your machine .
3. Install Go-Lang In Linux
You can install Go-Lang from source or binaries.
- The easiest way is to use your favorite package manager
$ apt-get install golang. This will fetch the latest release from GitHub and install it in your system.
- If you want to build from source, here are instructions on how to do it from here .
2. Installing Golang On Windows
To install Go on Windows, download the executable file from here .
Run the downloaded file by double-clicking on it or opening it with any program that allows you to execute files.
If you’re using Windows 10, right click on the executable and select Run as administrator to ensure that your computer won’t issue any errors after running this command.
Verify that Go is installed by opening your command prompt (CMD) and entering: go version . You should see something like this:
Check the version to verify a successful installation.
To check the version of Golang, run the following command:
$ go version
The output should be something like this: go version x.x.x or higher if you have not updated your installation yet.
If you’re still getting an error message, try restarting your computer and running the installation again. You can also try downloading the latest version of Go from their website .