Home / Web Development Training / GOLANG Programming Tutorial / How To Write The First Program in Golang !By Iqbal Trainer

How To Write The First Program in Golang !By Iqbal Trainer

Hello everyone and welcome you My go programming Tutorial

you May ask yourself why is doing a tutorial about Go

well basically go Brings Together the best of both words in

regards striking a balance between both dynamic as well as

statically compiled languages as you’re going to see the code is both

easy to read as well as a specification for Go is quite short even

though it includes ridiculous things like a built-in web server and yes

indeed I will cover that and basically decided to cover go

because it allows you to set up an appt quite easy and in this tutorial

going to cover all the basic syntax for the entire language so

I am basically going to leave installing go all up to you it is quite easy

just go to https://golang.org/dl/ and find whatever operating system using click

on it and install it and for the most part, you are just going to be using

a basic text editor as well as the terminal or if you are on windows you are

going to be using the command line and here we are I have a basic the text editor over here and here I have my terminal or my command line I am

going to type in code over here and executing it over there now

basically every go programs going to start with a package Declaration and

you just type in a package and main and this is basically going to provide us with the way

for us to reuse our code and in this situation I have main here because

this is going to be an executable program we are then going to be able to import all types of things

like here I am going to import a format package which is going to allow me to provide formatting for both

input and output you can have comments by just typing in two forward slashes // this like that or

you can have multi-line comments just by typing in a forward slash on a star and a whole bunch of things in a store in a closing

/ and I am going to move Quickly through this so if you want to

jump to any specific part just look in the description we are going to come in here and define a function this is going to be the

main function which is going to be called for execution wherever

the application is executed and function is going to open up with an opening curly bracket and closed with a closing curly bracket

we will get more into actually creating your own function

here in a little bit we are going to be able to use a function called

print line by referencing the formatting package and this is going to allow us

to output information on your screen and this is basically all you would need for a basic hello

world program inside go you can see over here we can execute a profile

and the name of it is here we go . go the extension is go and you would just type in go run

and whatever the name of your go program is you can see hello world prints out like that

no thanks kind of interesting if you have the terminal over here

you can just type in go doc and then whatever the package name is and then whatever function you

interested in is going to provide you all sort of information in regards to what that function does and how it operates.

 

go-lang-tutorial-12-638

 

 

 

 

 

 

 

 

Please share and leave Comment

Leave a Reply