Skip to content

Instantly share code, notes, and snippets.

@mvndaai
mvndaai / ctx.md
Last active October 28, 2024 19:42
Add ctx to all functions

Backaground

The package ctx was adding to Golang after people had started using requests. In order to use ctxerr you need context passed with every function that returns and error. This is a find and replace that adds ctx context.Context to all functions that return an error.

What to do

  1. Open VSCode or Curser and do an editor serach cmd + shift + f
  2. Set it to regex find by clicking the .* button

Keybase proof

I hereby claim:

  • I am mvndaai on github.
  • I am mvndaai (https://keybase.io/mvndaai) on keybase.
  • I have a public key ASAHrGwmzEQfyPmQrcsED-U2ewFxlcQKn43OZXltCt7CLgo

To claim this, I am signing this object:

@mvndaai
mvndaai / tabletest.go
Last active May 27, 2020 03:54
Go table test
package tabletest
import "errors"
//ForceError will return an error if the boolean is true
func ForceError(force bool) error {
if force {
return errors.New("forced error")
}
return nil

git

This is list of the git commands I use.

The usual flow of developed is clone or fork a repo, create a branch, change code, create commits at logical stopping points, push those commits, and finally merge the branch (usually done on a website).

Branches

Branches let you create a copy all the code from whatever branch you are on. This lets you make changes that can be merged back into the original branch, but doesn't effect the original. They help with conflicting changes by multiple people and code reviews.

Create new branch

@mvndaai
mvndaai / echo_with_colors.sh
Created September 27, 2014 02:41
Bash echo with colors
#!/bin/sh
echo-bold(){
echo -e '\e[1m'$1'\e[0m'
}
echo-black(){
#You probably shouldn't use this
echo -e '\e[30m'$1'\e[0m'
}
echo-red(){