Skip to content

Instantly share code, notes, and snippets.

View p000ic's full-sized avatar

p000ic p000ic

  • Toronto, Canada
View GitHub Profile
@p000ic
p000ic / dynamic_function_calls.go
Created March 5, 2022 08:02 — forked from bowmanmike/dynamic_function_calls.go
Golang Dynamic Function Calling
package main
import (
"fmt"
)
// Use map[string]interface{} to pair functions to name
// Could maybe use anonymous functions instead. Might be clean
// in certain cases
var funcMap = map[string]interface{}{
@p000ic
p000ic / context_cancel.go
Created May 10, 2021 19:43 — forked from fracasula/context_cancel.go
GoLang exiting from multiple go routines with context and wait group
package main
// Here's a simple example to show how to properly terminate multiple go routines by using a context.
// Thanks to the WaitGroup we'll be able to end all go routines gracefully before the main function ends.
import (
"context"
"fmt"
"math/rand"
"os"