Introduction to GoLanguage

Always learning
3 min readJun 3, 2024

Golang is an open-source web development language that was created by Google. This language has gained immense fame because of its top-notch security, concurrency and user-friendliness.

buymeacoffee ☕ 👈 Click the link

Features of Go Language

  1. Simplicity and Readability
  2. Concurrency Support
  3. Fast Compilation
  4. Static Typing
  5. Garbage Collection
  6. Standard Library
  7. Cross-Platform
  8. Tools and Ecosystem

UseCases

  1. Web Development
  2. Cloud and Network Services
  3. DevOps and Tooling
  4. Data Processing

Refer the installation guide

Download the Setup

Redirect the page

Installation done. Check Go version

go version

Write a sample “Hello-World” Program

package main

import "fmt"

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

Run a code

Basic Go language syntax & types

Packages

Imports

Functions

Variables

Control Structure

Error Handling

Every Go file starts with a package declaration, which provides a way for code to be reused. The main package is the starting point of a Go program.

packages main

This is where you include code from the other packages. The fmt package, for example, is commonly used for formatted I/O.

import "fmt"

Functions are declared with the fmt keyword. The main functions is the entry point of a Go program.

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

Variable can be declared using the var keyword, but also allows for short variable declaration with :=.

var x int = 10
y := 20 // short declaration

Go has control structure like if, for, switch, but no while (or) do while

for i := 0; i < 10; i++ {
fmt.Println(i)
}

Go handles error by returning an error type as a part of the functions return value.

func sqrt(x float64) (float64, error) {
if x < 0 {
return 0, errors.new("negative value")
}
return math.sqart(x), Nil
}

Types

Includes integers (int, uint, int8, uint8) floating points (float32, float64) complex numbers (complex64, complex128) boolean (bool)

Composite Types

Arrays → Fixed size list of elements of the same type

Slices → Dynamically sized, flexible view into the elements of anarray

Structs → Clooection of fields

Maps → Collection of Key-Value pairs

Read more

Thank you 🙏 for taking the time to read our blog.

--

--

Always learning

கற்றுக் கொள்ளும் மாணவன்...