Skip to content

Instantly share code, notes, and snippets.

@rsudip90
rsudip90 / nullHandle_extends.go
Last active January 3, 2024 21:46
database rows null handling in go by extending types
package main
import (
"database/sql"
"encoding/json"
"fmt"
"log"
"time"
"github.com/go-sql-driver/mysql"
@rsudip90
rsudip90 / translate.go
Created February 8, 2018 12:15 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
package main
import (
"net/http"
)
type SingleHost struct {
handler http.Handler
allowedHost string
}
package main
import (
"fmt"
)
func decorator(f func(s string)) func(s string) {
return func(s string) {
fmt.Println("Started")
@rsudip90
rsudip90 / cypress_AMI_dependencies_install.sh
Last active August 14, 2019 00:56
latest system update
#!/bin/bash
# This script installs the dependencies required by cypress.io tool
# on amazon linux AMI as the required dependencies are not easily available.
# path of dynamic executable of cypress
# for ex. /home/ec2-user/.cache/Cypress/3.0.1/Cypress/
CYPRESS_EXECUTABLE_FOLDER="/home/ec2-user/.cache/Cypress/<version>/Cypress"
exitError() {
@rsudip90
rsudip90 / valuer.go
Created November 23, 2017 13:23 — forked from jmoiron/valuer.go
Example uses of sql.Scanner and driver.Valuer
package main
import (
"bytes"
"compress/gzip"
"database/sql/driver"
"errors"
"fmt"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
@rsudip90
rsudip90 / main.go
Created August 10, 2017 17:26 — forked from kevburnsjr/main.go
Easy Middleware in Go
package main
import (
"net/http"
"time"
"log"
)
func main() {
dh := DispatchHandler{}
@rsudip90
rsudip90 / mysql57_yum.sh
Last active November 2, 2018 07:13
Automated mysql57 community server installation for yum-based linux distro - bash script
#!/bin/bash
# This script will download mysql version as specified in `MYSQL_RELEASE`
# Aim to install latest image of mysql release on machine of amazon linux AMI.
# Guidance: https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
MYSQL_RELEASE=mysql57-community-release-el6-11.noarch.rpm
MYSQL_RELEASE_URL="https://dev.mysql.com/get/${MYSQL_RELEASE}"
MYSQL_SERVICE=mysqld
MYSQL_LOG_FILE=/var/log/${MYSQL_SERVICE}.log
@rsudip90
rsudip90 / nullHandle.go
Last active February 1, 2023 03:34
How I handled the null possible value in a sql database row in golang?
package main
import (
"database/sql"
"encoding/json"
"fmt"
"reflect"
"time"
"github.com/go-sql-driver/mysql"