Skip to content

Instantly share code, notes, and snippets.

View Mayankgupta688's full-sized avatar
💭
Corporate and Online Trainer with 8+ years of Experience...

Mayank Gupta Mayankgupta688

💭
Corporate and Online Trainer with 8+ years of Experience...
View GitHub Profile
package main
import "fmt"
func main() {
returnedData := func() string {
return "This is Sample String Return Value"
}()
fmt.Println("Value Returned from Anonymous Function: %s", returnedData)
}
package main
import "fmt"
func main() {
func(inputData string) {
fmt.Println(inputData)
}("This is String Data")
}
package main
import "fmt"
func main() {
functionVariable := func() {
fmt.Println("Anonymous Function Executed")
}
functionVariable()
functionVariable()
package main
import "fmt"
func main() {
func() {
fmt.Println("Anonymous Function Executed")
}()
}
@Mayankgupta688
Mayankgupta688 / codeWithException.go
Last active February 15, 2023 04:32
codeWithException.go
package main
import "fmt"
func executeCode() {
fmt.Println("Defered Function call is Executed")
}
func main() {
username := "Mayank gupta"
defer executeCode()
@Mayankgupta688
Mayankgupta688 / gist:59c78e89762c4bcaa027670d1a7208e7
Last active February 15, 2023 04:27
cleanupCodeModifiedWithDefer.go
nupResources.go
package main
import (
"io"
"log"
"os"
)
func main() {
package main
import (
"io"
"log"
"os"
)
func main() {
if err := write("readme.txt", "This is a readme file"); err != nil {
package main
import "fmt"
func updateData(currentScope string) {
fmt.Println(currentScope)
}
func updateDataOther(currentScope string) {
fmt.Println(currentScope)
}
package main
import "fmt"
func updateData(currentScope string) {
fmt.Println("UserName value is ", currentScope)
}
func main() {
defer updateData("Defered Function Called")
currentScope := "Main Function"
package main
import "fmt"
func updateData(userName string) {
userName = "Mayank Gupta"
fmt.Println("Updated values is ", userName)
}
func main() {
userName := "TechnoFunnel"