Welcome To Golang By Example

Menu
  • Home
  • Blog
  • Contact Us
  • Support this website
Menu

Home

Note: Check out our golang advanced tutorial here

Also, check out our system design tutorial series here

About Golang

  • Golang Advanced Tutorial Series
  • About GOLANG
  • GO Installation
  • Set up GO Workspace and Hello World Program

Variables

  • Variables in Go - Complete Guide
  • Understanding var keyword in golang
  • Scope of a variable in golang
  • Naming conventions for variables and constant in golang
  • Understanding := symbol or short variable declaration in golang
  • Hello World in golang

Constant

  • Constant in Golang
  • Can constant be reassigned after its declaration in Go
  • Constant in inner/outer scope in Golang
  • Global and Local Constant in Golang
  • Typed and Untyped constant in Golang
  • Declaring a constant in Golang
  • String constant in Golang
  • Numeric/Integer/Float constant in Golang
  • Boolean constant in Golang
  • Character constant in Golang
  • Multiple constant declarations in Golang
  • Constant Map in Golang
  • Constant struct in Go (Golang)
  • Constant array or slice in Golang

Conditions and Loops

  • Understand if else in golang
  • for loop in golang
  • Switch Statement in Go
  • fallthrough keyword in go
  • for-range loop in Go
  • Goto statement in Golang

Packages/Modules

  • Packages and Modules in Go (Golang) - Part 1
  • Packages and Modules in Go (Golang) - Part 2
  • Modules in Golang
  • Direct vs Indirect Dependencies in go.mod file in Go
  • Manual download dependency from go.mod file in Golang
  • Selection of the version of library or dependency in Golang
  • Importing package from different module locally in Golang
  • Importing package within the same module in Golang
  • What does go mod tidy do in Golang
  • Add a dependency to your project or module in Golang
  • Executable and non-executable module in Golang
  • //indirect for a dependency in go.mod file in Golang
  • Understanding Module name or module import path in Golang
  • Vendor dependencies of a module in Golang
  • Understanding go.sum and go.mod file in Golang
  • Package vs Module in Golang
  • Remove a dependency from a module in Golang
  • Init function in Golang
  • Order of execution of a Go program
  • Nested Packages in Golang
  • Package Name and Directory/Folder Name in Golang- Does they need to be the same
  • Blank Identifier in import in Golang
  • Import same package name or Aliasing while importing packages in Golang

Array/Slice

  • Understanding Array in golang
  • Understanding slice in golang
  • Multi-Dimensinal Array and Slice in golang
  • Copy an array or slice in golang
  • Different ways of iterating over array and slice.
  • Check if an item exists in a slice
  • Find and delete an item in a slice
  • Find and delete an item in an array
  • Print an array or slice elements in golang
  • Declare/Initialize/Create an array or slice in golang
  • Convert an array/slice into a JSON string in golang
  • Append or Add to a Slice or Array in Golang
  • Slice of Struct in Golang
  • Slice of Map in Golang
  • Slice or Array of Channels in Golang
  • Slice or Array of Bool in Golang
  • Create Slice or Array of Integers in Golang
  • Create Slice or Array of Floats in Golang
  • Create Slice or Array of Strings in Golang
  • Sort a part of the slice in Golang
  • Append one slice to another slice in Golang
  • Sort a slice of Int in Ascending and Descending order in Go (Golang)
  • Convert an array of int or numbers to string in Go (Golang)

Maps

  • Different ways of iterating over map
  • Length of a map in golang
  • Maps in Golang - Complete Guide
  • Check if a key exists in a map in golang
  • Update a key in map in golang
  • Allowed key and value types for a map in golang
  • Create/Initialize/Declare map in golang
  • Conversion between map and JSON in Golang
  • Convert a map to JSON in Golang
  • Convert a JSON to map in Golang
  • How to check if a map contains a key in Golang
  • Delete or Remove a key from a map in Go (Golang)

Struct

  • Struct in golang - Complete Guide
  • Creating and Intializaing struct variables in golang
  • Pointer to a struct
  • Pretty Print Struct Variables in golang
  • Exported and non-exported fields of a struct
  • Anonymous Fields in a Struct in golang
  • Struct Equality in golang
  • Accessing and Setting Struct fields in golang
  • Nested Struct in golang
  • Struct Field Meta or Tags in golang
  • Conversion between struct and JSON in Golang
  • How to intialize a struct that has another nested struct in Golang
  • How to initialize a struct having an array or slice field in Golang
  • How to access the struct from another package in Golang

Method

  • Method in golang - Complete Guide
  • Pointer Receiver for a method in Golang
  • Method on a non-struct type in golang
  • Method chaining in golang

Interface

  • Interface in go
  • Pass an Interface as an argument to a function
  • Interface to struct
  • Embedding interface in go
  • Interface Comparison in golang
  • Benefits of Interface in golang
  • Pointer vs Value Receiver for interface in Go
  • Declaring and Implementing an interface in golang
  • Interface are implemented implicity in golang
  • Type implementing multiple interfaces in go
  • Print underlying type and value of an interface in golang
  • Inner working or internal of an interface in Golang
  • Non-Struct type implementing multiple interfaces in Golang
  • Zero value of an Interface in golang
  • Accessing underlying variable of an interface in Golang

Builtin Package

  • Copy function in golang
  • Append function in golang

Context

  • Using context in go – Complete Guide

GO Installation/Set-Up

  • Installing GO on MAC
  • Installing GO on Linux
  • Installing GO on Windows

Channel

  • Channel in Go
  • Inner working of Channels
  • Channel as a function argument in Go
  • Send and receive on a nil channel in Go
  • Close operation on a channel in Go
  • Channel Direction in Go
  • Length and capacity of a channel in Go
  • All operations/function on a channel in Go
  • Read/receive all values from a channel in Go
  • For-range loop for a channel in Go

Goroutines

  • Goroutines in Go
  • Number of currently running/active goroutines
  • Wait for all goroutines to finish execution
  • Receive or Fetch Return Value from a goroutine in golang
  • Receive or fetch multiple return values from a goroutine in golang
  • Pause Execution of a goroutine until an activity or event is completed in Golang

Select

  • Select Statement in Go
  • Select statement with a for loop outside in Go
  • Select with default case in Go
  • Select with send operation in Golang
  • Select statement with a nil channel in Golang
  • Select versus switch in Golang
  • Fallthrough keyword in select statement in Golang
  • Break statement in Select in Golang
  • Execute multiple case in Select statement in Golang
  • Empty select or select with no case in Golang
  • Select statement with timeout in Golang

Data Types

  • All data types in Go with examples
  • All basic data types in Golang
  • Know Size and Range of int and uint
  • Default Value of all types with examples
  • Character in Golang
  • uintptr in Golang
  • Rune in Golang

Pointer

  • Pointer in Golang
  • Pointer to a Pointer in Golang
  • * or dereferencing pointer in Golang
  • Pointer Arithmetic in Golang
  • Default zero value of pointer in Golang

IOTA

  • IOTA in Golang
  • Convert an IOTA or Enum to a string in Go (Golang)

Enum

  • Enum in Golang

String

  • Check if string is a number
  • Remove all white spaces from a string
  • Write a multiline string in Go
  • String compare in GO
  • Check if a string contains another string in GO
  • Split a string by delimiter in Go
  • Get all the words from a sentence
  • Join a string by delimiter or a separator in Go
  • Check if string begins with a prefix in Go
  • Check if string ends with a suffix in Go
  • Convert string to lowercase in Go
  • Convert string to uppercase in Go
  • Capitalize a string in Go
  • Trim prefix of a string in Go
  • Trim suffix of a string in Go
  • Trim leading and trailing whitespaces from a string
  • Count instances of substring in a string in Go
  • Find index of first instance of a substring in Go
  • Replace all instances of a substring with another in Go
  • Replace some instances of a substring with another in Go
  • Replace a character with another in a string in Go
  • Find the index of the last instance of a substring in Go
  • Index character in a string in Go
  • Generate all permutation of a string in Go
  • Swap characters of a string in Go
  • Swap two strings in Go
  • Reverse a string in Go
  • Find and detete a character in Go
  • Find and delete a substring in Go
  • Delete in a string by index in Go
  • Create count/repeating copies of a string in GO
  • Case insensitive comparison of two strings in Go
  • Number of Characters in a string in Go
  • Get ASCII code of any Alphabet or Number in Go
  • Iterate over a string in golang
  • Length of a string in golang
  • ASCII digit to the character in Golang
  • Write to write or print backslash in a string in Golang
  • Print string with double quotes in Golang
  • Sort a string in Golang
  • Create or initialize a new string in Go (Golang)
  • Check if a string contains single or multiple whitespaces in Go (Golang)

Math

  • Ceil of a number in Go
  • Floor of a number in Go
  • Get Integer value of a float in Go
  • Round a number in Go
  • Round Even a number in Go
  • Remove Decimarl parts of a float in Go
  • Get Absolute value of a number
  • Pi value in Go
  • Square root of a number in Go
  • Cube Root of a number in Go
  • Log of a number in Go
  • Remainder or Modulus in Go
  • Break a number into integer and fraction parts in Go
  • Power function in Go
  • Check if a number is positive or negative in Go
  • Min of two numbers in Go
  • Max of two numbers in Go

Random

  • Generate random number in Go
  • Generate random password
  • Pick a random element in an array/slice in Go
  • Pick a random character in string in Go
  • Shuffle a string in Go
  • Shuffle a slice or array in Go
  • Generate a random array/slice of n integers in Go
  • Generate a number in a given range
  • Generate a random string in Go

Float

  • Parse string representation of a float

Bool

  • Parse string representation of a bool
  • Format specifier for boolean in golang

Sync

  • Understanding WaitGroup in Go

Loop

  • Implement while loop in Go

Function

  • Immediately Invoked Function in Go
  • Function Closures in Go
  • Pass Function as an argument to another function
  • Return a function from another function
  • Pass Variable Number of Arguments to a function
  • Difference between function and method
  • Anonymous Function in Go
  • Higher Order Function in Go
  • User Defined Function Type
  • Return Multiple Values from a function
  • Function in Golang - Complete Guide
  • How to call a function from another package in Golang

Defer

  • Defer keyword in Golang
  • Defer a goroutine in Golang
  • Use Case of defer function in Golang
  • Inline Function in Defer in Golang
  • Evaluation of defer arguments in Golang
  • Custom Function in defer in Golang
  • How does defer works in Golang
  • Defer function and Named Return Values in Golang
  • Multiple defer functions in Golang
  • Defer and Methods in Golang
  • Can defer be used inside main function in Golang

Panic & Recover

  • Panic and Recover in Golang
  • Recover a panic in a different function in Go
  • Panic with Defer in Golang
  • Runtime Error Panic in Golang
  • Panic format string in Golang
  • Recover panic from goroutine in Golang
  • Return value of the function when panic is recovered in Golang
  • Recover function return value in Golang
  • Panic stack trace in Golang
  • How to create panic in Golang
  • Example of Recover Function in Golang
  • What happens during panic in Golang
  • Create panic by calling panic function in Golang
  • Base64 encoding/Decoding in Golang

Generic Articles

  • NewRelic in Go with deep instrumentation
  • Redis Client Example
  • Redis Cluster Client Example
  • Maps: Not safe for concurrent use
  • Octal and Hex in Go
  • Double, Single and Back Quotes in Go
  • All types of Client timeouts in (HTTP/TCP/UDP/ Unix Sockets Communication ) etc
  • Generate a UUID/GUID in Go (Golang)
  • Server Error - 500 vs 502 vs 503 vs 504
  • Print/Output text in color in console
  • Print/Output text in bold in Golang
  • Print/Output text in italic in Golang
  • Print/Output text with a background in Golang
  • Print/Output crossed-out text in Golang
  • Print/Output text in underline in Golang
  • Format a message without printing in Golang
  • All about Base64 encoding/decoding - Complete Guide
  • HTTP- Understanding multipart/form-data content-type

Object-Oriented Programming in GO

  • Inheritance
    • OOP: Inheritance in GOLANG complete guide
    • Using Struct
    • Using Interface
    • Using Interface + Struct
  • Polymorphism
    • OOP: Polymorphism in Go Complete Guide
    • Compile Time Polymorphism in Go (Golang)
    • Runtime Polymorphism in Go (Golang)
    • Method Overloading in Go (Alternatives/Workarounds)
  • Abstract Classes
    • Abstract Class in Go: Complete Guide
  • Encapsulation
    • Encapsulation in Go

Protocol Buffers

  • Protocol Buffer And Go: Getting Started

fmt package

  • Println vs Print vs Printf in Golang
  • Understanding Errorf function in Golang
  • Understanding Fprintf function in Golang
  • Understanding Fprint function in Golang
  • Understanding Fprintln function in Golang
  • Understanding Println function in Golang
  • Understanding Printf function in Golang
  • Understanding Print function in Golang

GRPC

  • Difference between GRPC and Rest

Design Patterns

  • All Design Pattern in GO - Curated List
  • Creational
    • Abstract Factory Pattern
    • Builder Pattern
    • Factory Pattern
    • Object Pool Pattern
    • Prototype Pattern
    • Singleton Pattern
  • Behavioral
    • Chain of Responsibility Design Pattern
    • Command Design Pattern
    • Iterator Design Pattern
    • Mediator Design Pattern
    • Memento Design Pattern
    • Null Object Design Pattern
    • Observer Design Pattern
    • State Design Pattern
    • Strategy Design Pattern
    • Template Method Design Pattern
    • Visitor Design Pattern
  • Structural
    • Adapter Design Pattern
    • Bridge Design Pattern
    • Composite Design Pattern
    • Decorator design pattern
    • Facade Design Pattern
    • Flyweight Design Pattern
    • Proxy Design Pattern

Files

  • Read
    • Read a large file Word by Word in Go
    • Read a large file Line by Line in Go
    • Read a file into a variable in Golang
  • Write
    • Write to a file in Go
    • Append to a file
  • Delete
    • Delete a file in Go
    • Delete a folder in Go
  • Update
    • Change the updated/modified time of a file in Go
  • Rename
    • Rename a file or folder
  • Generic
    • Check if a file is a directory in Go
    • Create an empty file in Go
    • Check if a file or directory exists in Go
    • Iterate over a directory tree
    • Get Current Working Directory in Go
    • Touch a file in Go
    • Move file from one location to another
    • Get File Name, Size, Permission Bits, Mode, Modified Time in Go
    • Copy a file in Go

Folder/Directory

  • Create a directory
  • Change Current Working Directory in Go

Validation

  • Validate the presence of the field in a struct in Golang
  • Validate the range of the integer in a struct in Golang

Time

  • All about time and date in Go
  • Represent date of birth in golang.
  • Get age given a dob
  • Current Timestamp in Go
  • Date/Time fomatting in Go