Skip to content

Instantly share code, notes, and snippets.

View danielfbm's full-sized avatar
🎸

Daniel Filipe Bruehmueller Morinigo danielfbm

🎸
View GitHub Profile

Keybase proof

I hereby claim:

  • I am danielfbm on github.
  • I am danielfbm (https://keybase.io/danielfbm) on keybase.
  • I have a public key ASBS72HgFQI2hRtQPdk_oeqNeFRjKBF9elS9W3poLKYicQo

To claim this, I am signing this object:

package main
import (
"time"
redis "gopkg.in/redis.v5"
)
// CircuitBreaker responsible for creating a circuit breaking
// logic for redis client
@danielfbm
danielfbm / something.go
Created May 18, 2017 08:58
change a json key's value
package main
func main() {
var data interface{}
ctx.ReadJSON(&data)
if obj, ok := data.(map[string]interface{}); ok {
obj["name"] = ""
} else if array, ok := data.([]interface{}); ok {
@danielfbm
danielfbm / singleton.go
Created February 4, 2017 16:13
golang singleton design pattern
package main
import (
"fmt"
"sync"
)
type MyStruct struct {
Name string
}
@danielfbm
danielfbm / git2go-merge-local-branch.go
Last active June 1, 2020 01:49
how to merge two local branches using git2go
package main
import (
"errors"
"log"
"github.com/libgit2/git2go"
)
func mergeBranches(repo *git.Repository, sourceBranchName string, destinationBranchName string) error {
// Assuming that these two branches are local already
sourceBranch, err := repo.LookupBranch(sourceBranchName, git.BranchLocal)
@danielfbm
danielfbm / git2go-checkout-branch.go
Last active June 8, 2023 07:43
How to do a git checkout branch using git2go
package main
import (
"errors"
"log"
"github.com/libgit2/git2go"
)
func checkoutBranch(repo *git.Repository, branchName string) error {
checkoutOpts := &git.CheckoutOpts{