now we will learn the Go or Golang programming language. What is Golang?

Go or Go Language, commonly abbreviated as Golang, is a programming language created and developed by the Google team. This language was created by the google development team in 2007 and released to the public in 2009. Making golang is based on the C and C ++ languages. This is what causes Golang and C to have a fairly similar syntax. Unlike most new programming languages, Golang does not adopt Object Oriented or Generic programming.

This language was originally created only for Google’s internal company, but in 2009 Golang was finally released to the public in an open-source manner which means that the code is open, can be written, modified, and redistributed.

One of the famous Golang developer members is (Ken Thompson), a computer scientist who is also known as the developer of the Unix operating system. The other members of the team are Robert Griesemer and Rob Pike.

Golang is one of top 12 the most popular programming language in the world.

What can be made with Golang?

Golang can be used as a beck end language for any program, be it website, mobile, and others. This language is usually used to create RestAPI, due to its friendlier syntax and efficiency that is not inferior to the C language. As we all know efficiency is one of the most important things in choosing a programming language. In the world of programming efficiency is a process in which few resources are used to achieve the expected results.

Here are some applications made using golang:

Advantages of Golang

Just like other programming languages, Golang certainly has advantages over other programming languages. Here are some of the advantages possessed by Golang:

Golang Writing Rules

Each programming language has a different structure and writing rules. Here are some writing rules and the use of certain functions in golang.

Method main


package main

import "fmt"

func main(){
	// kode disini
}

Import package in Golang

Packages are used to use certain functions. For example, the code below shows import “fmt” is used so that the program can use the fmt package .


package main

import "fmt" // kode import

func main(){
	// content main
}

Display writing


package main

import "fmt"

func main(){
	fmt.Println("Halo dunia!")
}

To display the text in the golang program, the code fmt.Println (“Posts here”) is used , where previously we had to import the fmt package in order to use Pintln (“”) .

Data Types and Variables

Broadly speaking, in Golang there are three types of data types, namely number, string, and boolean. Number data types are data types that contain numbers which are divided into two, namely integers (whole numbers) and floating point (decimal). The integer itself is further divided into:

Apart from the two types of Integers above there are still bytes but this type of integer is rarely used. To understand more about data types, the following is an example of a program that combines variables with data types.


package main
 
import "fmt"
 
func main() {
    a := "Codingrakitan.blogspot.com" 
    b := 7 
    c := true 
    fmt.Println("a = ", a)
    fmt.Println("b = ", b)
    fmt.Println("c = ", c)
}

The code above will display the program as shown:

Get to know the Go or Golang programming language

Kondisi if else


package main

import "fmt"

func main(){
	a := 10
	
	if a > 10 {
		fmt.Println("Nilai a lebih besar dari 10")
	}else{
		fmt.Println("Nilai a tidak lebih besar dari 10")
	}

}

The code above shows a condition where if a> 10 then displays the words Value a is greater than 10, if not or otherwise, then display the words Value a not greater than 10 .

The For loop

Here is an example program using the for loop system:


package main

import "fmt"

func main(){
	for i := 0; i < 5; i++ {
    fmt.Println("Nilai = ", i)
}

The code above will display the value of writing five times with the value of i changing from 0 to 4. Why it starts from 0 because the variable i is initially formulated as i: = 0 , then why only goes to 4 because i <5 means i is less than 5.

Write a comment

Comments are very useful for marking as well as providing information on a certain section. The use of comments on the program is very useful if the application that has been created includes a lot of code, and helps programmers in doing teamwork. There are two types of comments on golang, namely inline comments (one line) and multi line comments (many lines). Inline comments use the // sign while multi-line comments use a line opening / * and a line closing * / . To better understand, see the example below:


package main

import "fmt"

func main(){
	// ini adalah komentar inline
}

 


package main

import "fmt"

func main(){
	/* ini adalah 
	jenis
	komentar multi line */
}

On the official site golang.org you can see that golang can be installed on Windows, MacOS, or Linux platforms.