123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computer-Programming >> View Article

Go Green: Setting Up Go And Crafting A Basic 'hello World' Project In Golang

Profile Picture
By Author: Madhumati
Total Articles: 14
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

Skills Required:

• Basic Programming Knowledge: Understanding fundamental programming concepts like variables, data types, loops, conditional statements, and functions.
• Basic Command line interface (CLI): Comfort with navigating through the command line interface is beneficial as you might need to execute commands to install Go and manage your Go projects.
• Understanding of Development Environments: Basic knowledge of working in an Integrated Development Environment (IDE) or a text editor like Visual Studio Code can be advantageous for setting up the Go development environment.

Go Programming Language:

Go was originally built for programs related to networking and infrastructure. It was intended to replace popular high-performance server-side languages like Java and C++. Go, also called Golang or Go language. It is an open-source programming language developed by Google.

The history of Go:

Google created Golang to solve its software engineering issues and to provide an alternative to C++. Google began designing Go in 2007 by Robert Griesemer, Rob Pike, Ken Thompson and ...
... in 2009 Google announced Go is an open-source project where community members could collaborate on ideas and code. Version 1.0 was later released in 2012.

Golang vs. Java: Performance

Concurrency:
• Golang has built-in support for concurrency with go-routines and channels.
• Java has concurrency features like threads and synchronized blocks.

Compilation:
• Golang is a compiled language with fast compilation times.
• Java is c compiled language that can also be interpreted through the use of a JVM.

Garbage collection:
• Golang has a concurrent garbage collector which does not stop the program execution.
• Java has a garbage collector that may pause the program execution to free memory.

Package management:
• Golang has a built-in package management system called “go modules”.
• Java uses external package management tools like Maven and Gradle.

Performance:
•Golang is known for high-performance and low-latency processing capabilities.
•Java is relatively slower in terms of performance due to its virtual machine architecture.

Installation of Go on Visual Studio Code:

•Go on Browser and type Download Go, and then you will get the very first link go. dev.
•Go to go. dev link and you will see featured downloads under which based on your operating system download the file.
•After downloading the installer file, just go to the installer file (Where you saved the installer file).
•Simply double-click on the installer file and it will start the setup Wizard.
•Wizard will say “Welcome to the Go programming Language Setup Wizard “.
•Just click on the Next button.
•Then accept the license agreement and click on the next button.
•Destination folder – no need to change the default setting just click on the next button.
•Then Wizard will say “Ready to install Go programming language” Just click on the install button.
•Your system will ask you about changes to be made in your system – say yes.
•It will start the installation process, It will take a little time to install Go on your system.
•Finally, click on the Finish button.

Setting environment variable on windows:

•Go to Edit the system environment variables (control panel).
•Click on Environment variables button.
•Click on New Button and Go path here.
•Choose Go path. (ex: C:\Users\\go)
•Click ok.

Installation of Go on Visual Studio Code:
•Open Visual Studio Code.
•Go to Extension.
•Search extension – Go (by golang.go)
•Click on install button.
•Once it installed you are ready to work on Golang projects.

Simple HelloWorld Programme:

•Create hello-world directory.
cd mkdir hello-world (Type it in cmd)
•Type “code .” to open Visual Studio code
•Create a file with filename as – main.go
•Type below code,

package main

import "fmt"

func main() {
fmt.Println("Hello World!")
}


•Open terminal and run below command,
go run hello-world/main.go

O/P: Hello World!

Below is the explanation of above code:

•Package main – We are declaring a package called main here because will need to declare the main() function, which can only be declared in a package named main.
•Import “fmt” – The fmt package provides functions to print.
•func main() – The main() is a special function that is executed first when the program starts. The main() function in Go should always be declared in the main package.
•fmt.Println(“Hello world!”) – It prints the passed argument to the standard output together with a new line.

Conclusion:

Go (Golang) stands as a powerful language for backend development renowned for its concurrency support and performance advantages over established languages like Java. Installation of Go on visual studio code sets the stage for seamless Go development, empowering beginners to initiate coding journeys effortlessly.

Credit- Madhumati S.

MetricsViews Pvt. Ltd.
MetricsViews specializes in building a solid DevOps strategy with cloud-native including AWS, GCP, Azure, Salesforce, and many more. We excel in microservice adoption, CI/CD, Orchestration, and Provisioning of Infrastructure - with Smart DevOps tools like Terraform, and CloudFormation on the cloud.

www.metricsviews.com

Total Views: 266Word Count: 739See All articles From Author

Add Comment

Computer Programming Articles

1. Linq Tutorial In C#: Learn Language Integrated Query Step By Step
Author: Tech Point

2. Digital Marketing Company In Delhi: Helping Businesses Build A Strong Online Presence
Author: Code Sparrow

3. Connected Living And Digital Transformation With Custom Iot And Home Automation Solutions
Author: John Smith

4. Why Businesses Need Custom Conversational Ai Chatbots
Author: Fasturex

5. Cmmc 2.0 Compliance Consulting For Defense Contractors
Author: CMMC

6. Building A Stronger Cybersecurity Culture With Security Awareness Programs
Author: Sam Vohra

7. Kotlin Tutorial: A Complete Guide To Kotlin Programming For Beginners
Author: Tech Point

8. Dart Tutorial: Learn Dart Programming Concepts From Basics To Advanced
Author: Tech Point

9. Checklist: What To Consider Before You Hire Software Developers In India
Author: Nevil Martin

10. Manual Vs Automated Time Tracking For Freelancers: Which Approach Makes More Sense?
Author: Aiwi

11. Jenkins Tutorial For Beginners: Learn Continuous Integration Step By Step
Author: Tech Point

12. Docker Tutorial With Practical Examples To Master Containerization
Author: Tech Point

13. Why Website Development Is Essential For Digital Success
Author: Rudram Technology Solutions

14. Dynamics 365 Business Central Cloud
Author: brainbell10

15. Sap Successfactors Access Management: How To Close The Jml Gap Across Every Connected System
Author: Mansoor Alam

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: