Article
Closure in go
closure is a function inside another function where you can reference variable defined in the outer function.
I have seen them useful in dealing with packages where a function expects an type func() as an argument where the func() doesn’t take any argument.
example from package github.com/cenkalti/backoff
signature of backoff.Retry is as below
backoff.Retry(o backoff.Operation, b backoff.Backoff) where backoff.Operation is of type func() error
type Operation func() error func main() { func retryWrapper(imp string) func() error{ return func() { funcThatCouldFail(imp) retun nil } } err := backoff.
Article
defer statement in go
defer is one of the unique keywords in Go.
What does defer do? As the name suggests, it defers something. It defers function calls. A deferred function gets invoked right after the surrounding function returns.
func outer() { defer inner() log.Println("outer got called") } func inner() { log.Println("inner got called") } outer got called prints first then inner got called.
What the main use of defer statement? It helps mainly with actions that need to happen but not immediately.
Article
Notes on concurreny in Golang
Concurrency channels are like typed pipes, Where you can send something from one side and receive from other side. using channel direction operator <-. Depends on the direction of the variables around the operator, its either sending or receiving. x := <-c // receive from c c <- sum // send sum to c fmt.Println(“channel receive happening”, <-c) channels are reference type. similar to maps. So when we pass channel as an argument to a function or copy we are passing the reference.
Article
Getting Started with JWT
Disclaimer: Whatever I write here is my learnings. So, don’t take these words as granted or reference. Also, please lmk if there are any errors.
I have often come across this term JWT. I knew the definition - Json Web Token, but honestly that’s all I knew for a veryyyy longgg time. Recently, I came across a problem where I have been told that JWT might be a good solution for it.
Article
Setting up ghost in raspberry pi for free
This is part of my Today I Learnt series where I share whatever I am learning something new. After having issues with port forwarding in Xfinity I decided to look for alternative solutions. I have used Cloudflare tunnel (used to be called Argo Tunnel) in the past to expose websites running on my laptop to the Internet. So, I decided to try it out for Ghost blogging site which I am setting up for my dad.
Article
port forwarding in xfinity
This article is part of my Today I Learnt. I have been trying to share whatever I learnt newly on the day. Some of them are basic, but still I want to write it down for two reasons. 1. To help me understand the concepts better 2. Potential help other people who running in to same issue.
Alright, It’s all started when I bought a new domain (synergy.net) for my Dad.