Welcome To Golang By Example

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

Tag: go

Can defer be used inside main function in Go (Golang)

Posted on September 23, 2020September 23, 2020 by admin

Overview Defer as the name suggests is used to defer the cleanup activities in a function. These cleanup activities will be performed at the end of the function. defer can be used…

Defer and Methods in Go (Golang)

Posted on September 23, 2020September 23, 2020 by admin

Overview defer statement is also applicable  for methods in a similar way it is applicable to functions. Let’s see an example Example In the above program, we do defer file.Close() after opening…

Defer function and Named Return Values in Go (Golang)

Posted on September 22, 2020September 22, 2020 by admin

Overview In case of named return value in the function, the defer function can read as well as modified those named return values. If the defer function modifies the name return value…

Multiple defer functions in Go (Golang)

Posted on September 22, 2020September 22, 2020 by admin

Overview There can be two cases of multiple defer functions Multiple Defer function within a particular function Multiple Defer function in different functions Before we see an example for both let’s see…

What happens during panic in Go (Golang)

Posted on September 22, 2020September 22, 2020 by admin

Overview Let’s understand what happens when panic happens in a program. Imagine a function call from main function to f1 function to f2 function main->f1->f2 Now let’s say that panic happens in…

How does defer works in Go (Golang)

Posted on September 22, 2020September 22, 2020 by admin

Overview When the compiler encounters a defer statement in a function it pushes it onto a list. This list internally implements a stack-like data structure.  All the encountered defer statement in the same function…

Custom Function in defer in Go (Golang)

Posted on September 21, 2020September 21, 2020 by admin

Overview We can also call a custom function in defer. Let’s see a example for that Example Output In the above program there is a defer statement calling the custom function named…

Evaluation of defer arguments in Go (Golang)

Posted on September 21, 2020September 21, 2020 by admin

Overview defer arguments are evaluated at the time defer statement is evaluated Let’s see a program for that Example Output In the above program when the defer statement was evaluated the value…

Inline Function in Defer in Go (Golang)

Posted on September 21, 2020September 21, 2020 by admin

Overview It is also possible to have an inline function with defer. Example Let’s see an example of that. Output In the above code we have defer with a inline function This…

Use Case of defer function in Go (Golang)

Posted on September 21, 2020September 21, 2020 by admin

Overview Defer as the name suggests is used to defer the cleanup activities in a function. These cleanup activities will be performed at the end of the function. This cleanup activities will…

Posts pagination

Previous 1 … 25 26 27 … 44 Next
Follow @golangbyexample

Popular Articles

Golang Comprehensive Tutorial Series

All Design Patterns in Go (Golang)

Slice in golang

Variables in Go (Golang) – Complete Guide

OOP: Inheritance in GOLANG complete guide

Using Context Package in GO (Golang) – Complete Guide

All data types in Golang with examples

Understanding time and date in Go (Golang) – Complete Guide

©2025 Welcome To Golang By Example | Design: Newspaperly WordPress Theme