Go is a general-purpose language designed with systems programming in
mind.It was initially developed at Google in year 2007 by Robert
Griesemer, Rob Pike, and Ken Thompson. It is strongly and statically
typed, provides inbuilt support for garbage collection and supports
concurrent programming.
পৃষ্ঠাসমূহ
Labels
Search Your Article
CS
Pageviews
Showing posts with label Go Tutorial. Show all posts
Showing posts with label Go Tutorial. Show all posts
Thursday, February 2, 2017
Go - Environment Setup
Try it Option Online
You really do not need to set up your own environment to start learning Go programming language. Reason is very simple, we already have set up Go Programming environment online, so that you can compile and execute all the available examples online at the same time when you are doing your theory work.
Go - Program Structure
Before we study basic building blocks of the Go programming language,
let us look a bare minimum Go program structure so that we can take it
as a reference in upcoming chapters.
Go - Basic Syntax
You have seen a basic structure of Go program, so it will be easy to
understand other basic building blocks of the Go programming language.
Go - Data Types
In the Go programming language, data types refer to an extensive
system used for declaring variables or functions of different types. The
type of a variable determines how much space it occupies in storage and
how the bit pattern stored is interpreted.
Go - Variables
A variable is nothing but a name given to a storage area that our
programs can manipulate. Each variable in Go has a specific type, which
determines the size and layout of the variable's memory; the range of
values that can be stored within that memory; and the set of operations
that can be applied to the variable.
Go - Constants
The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals.
Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well.
The constants are treated just like regular variables except that their values cannot be modified after their definition.
Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well.
The constants are treated just like regular variables except that their values cannot be modified after their definition.
Go - Operators
An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations. Go language is rich in built-in
operators and provides the following types of operators:
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Misc Operators
Go - Decision Making
Decision making structures require that the programmer specify one or
more conditions to be evaluated or tested by the program, along with a
statement or statements to be executed if the condition is determined to
be true, and optionally, other statements to be executed if the
condition is determined to be false.
Go - Loops
There may be a situation, when you need to execute a block of code
several number of times. In general, statements are executed
sequentially: The first statement in a function is executed first,
followed by the second, and so on.
Go - Functions
A function is a group of statements that together perform a task. Every Go program has at least one function, which is main(), and all the most trivial programs can define additional functions.
Go - Scope Rules
A scope in any programming is a region of the program where a defined
variable can have its existence and beyond that variable can not be
accessed. There are three places where variables can be declared in C
programming language:
Go - Arrays
Go programming language provides a data structure called the array,
which can store a fixed-size sequential collection of elements of the
same type. An array is used to store a collection of data, but it is
often more useful to think of an array as a collection of variables of
the same type.
Go - Pointers
Pointers in Go are easy and fun to learn. Some Go programming tasks
are performed more easily with pointers, and other tasks, such as call
by reference, cannot be performed without using pointers. So it becomes
necessary to learn pointers to become a perfect Go programmer. Let's
start learning them in simple and easy steps.
Go - Structures
Go arrays allow you to define type of variables that can hold several data items of the same kind but structure is another user defined data type available in Go programming, which allows you to combine data items of different kinds.
Go - Slices
Go Slice is an abstraction over Go Array. As Go Array allows you to
define type of variables that can hold several data items of the same
kind but it do not provide any inbuilt method to increase size of it
dynamically or get a sub-array of its own. Slices covers this
limitation. It provides many utility functions required on Array and is
widely used in Go programming.
Go - Range
The range keyword is used in for loop to iterate over
items of an array, slice, channel or map. With array and slices, it
returns the index of the item as integer. With maps, it returns the key
of the next key-value pair. Range either returns one value or two. If
only one value is used on the left of a range expression, it is the 1st
value in the following table.
Go - Maps
Go provides another important data type map which maps unique keys to
values. A key is an object that you use to retrieve a value at a later
date. Given a key and a value, you can strore the value in a Map object.
After value is stored, you can retrieve it by using its key.
Go - Recursion
Recursion is the process of repeating items in a self-similar way.
Same applies in programming languages as well where if a programming
allows you to call a function inside the same function that is called
recursive call of the function as follows.
Go - Type Casting
Type casting is a way to convert a variable from one data type to
another data type. For example, if you want to store a long value into a
simple integer then you can type cast long to int. You can convert
values from one type to another using the cast operator as following:
Subscribe to:
Posts (Atom)