Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation, easy programming and fast execution.
Go Programming language was designed by Google in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson with an aim for it to be “C for the 21
century”. It is basically an open-source, general-purpose, statically-typed language and belongs to the C-family. So users who are familiar with C programming syntaxes might not find it difficult. The need for this new language was generated because C/C++ didn’t evolve corresponding with computing landscape. In past decade no other system language was introduced to fit the requirements to this evolving computing era. Hence, Go Programming language emerged as a low-level language which was equipped with higher concepts. It was presented as an efficient language with fast compilation, easy programming, and fast execution. Programs here are generated by means of packages for accurate management of dependencies. This language uses a traditional compile and link model for generation of executable binaries.
Traits of Go Programming
- Go language supports the dynamic language-like environment adopting patterns for ease of programming. This language is type-safe and also memory-safe.
- Minimal amount of keywords are used concisely in order to reduce the complexity and clutter in coding. Design concepts also are less complex and being Orthogonal do not interrupt.
- Like Java and C++, Go language is not object-oriented and is not integrated with concepts like inheritance and classes. But it supports concept of interfaces and hence some extent of polymorphism can be achieved.
- Despite of being embedded with expressive type-system, it is lightweight and does not represent hierarchy and thus it can be called as hybrid language.
- Go was conceptualized as systems programming language to be used in heavy web servers, networking systems, storage architectures, and similar fields and it surpassed as productive language.
- It can fit well for needs of game server development, complex event processing (CEP), text-processing problems, scripting-like applications, etc.
Installation for Distinct Platforms
- Some of the features have been removed as well which include; no function operator, no implicit conversions, no classes or type inheritance, no dynamic code loading, no generics, no dynamic libraries, no exceptions, no assertions, no immutable variables, etc.
Different compilers were developed for below mentioned Operating Systems:
Go1 is available in source and binary form for below mentioned platforms;
Step-wise Installation of Go on Windows System
- FreeBSD 7+: amd64, 386
- Linux 2.6: amd64, 386, arm
- OS X: amd64, 386
- Windows (2000 + later): amd64, 386
Perform Go Installation on Windows
Users can install the Go language program either by downloading:
Separate files are available for Windows 32 bits and 64 bits Operating System architectures.
- Download the files according to the Architecture:
- Extract the .zip file and extract to the directory (prefer C:\Go).
- If you choose any other directory (not C:\Go), then you will have to set GOROOT environment variable.
- Add the bin subdirectory of Go root (C:\Go\bin) to Path available in Environment Variable option. (This can be done by editing the Path option in Environment Variable available in Computer>>Properties>>Advanced System Settings>> Advanced.)
- Download the MSI installer files as per Architecture:
- Double-click the MSI file and install it as per prompted.
- By default Go distribution will be saved to C:\Go.
- Put the C:\Go\bin directory in the PATH available in Environment Variable.
We have installed the Go program using MSI Installer. It is easy for installation and the System variables are added implicitly. If you are going to download the Zip file, you will have to add the System Variables manually. In the same option, go to PATH and add the directory of GOBIN to the PATH by editing it.
Check the Installation is Successful or Not
Once the installation is done, users can check whether it was installed successfully or not by running a basic program. Before that try to run some basic commands using Command Prompt.
- Check if Go folder is created in C drive or not.
- Start Command Prompt (cmd) and direct it to C:\Go and the run “Go version” command.
- Type go and details about Go programming language will be displayed along with the commands.
Method to Create Directories
- Create a new folder for saving the programs. Here we created a folder in C drive as “Go Projects”.
- Direct to this newly created folder and make directories following the below mentioned mkdir commands.
Get a Text Editor for Writing Programs
A Go program has to be written in text files with the extension “.go”. Any text editor can be used for writing programs. Here we have used Sublime Text2 Editor for creating programs in which the source code for program is written.
: You can take help of any Text Editor as per your convenience and OS available like; Windows Notepad, Epsilon, SciTE, OS Edit command, Brief, EMACS, Xcode3, KD Kate, BBEdit, JEdit, Notepad++, SlickEdit, NetBeans, and vim or vi.
Check the Installation Via Simple Program
- Write a basic program which will give Output “Hello Windows” using Sublime Text Editor.
- Copy the below mentioned source code:
- The first line defines the package name where the program lies. This statement is a must as Go programs runs in packages. main package can be depicted as starting point for running the program.
- Next is import fmt which is preprocessor command pointing Go compiler to include files lying in package fmt.
- Next is func main () where the execution starts.
- If any comment is provided /*_*/, it will not be read by compiler.
- Next is fmt.Println (…) is another function displaying the message “Hello Windows”. fmt package exports Println method for displaying this message.
- The program in Sublime will appear as;
- Save this text file as hello.go in the same folder which was created for Go programs i.e. Go Projects folder.
Execute the Program Using CMD
- Run the hello.go in order to see the output.
- Type below mentioned commands;
- Check the Output Results:
So this is the basic guideline to try your hands on Go programming language. This will introduce you with the 21
century programming style. It is easy for installation which can be checked using the basic program stated above. Of course this is just a beginning and there is a way to go learning about Types and Variables used by Go, Collection Types, Strings, pointers, Procedural/O-O Programming, Concurrent Programming, File handling, Packages, Application in Go, etc. But this will help you to have a headstart for Go language.