Skip to content

Instantly share code, notes, and snippets.

View indraoct's full-sized avatar

Indra Octama indraoct

View GitHub Profile
@indraoct
indraoct / chanel.go
Created July 20, 2024 16:58
Example Chanel
...
func main() {
var (
ch = make(chan string) //initiate chanel
retrieveData string
dDownload []dataDownload
)
dDownload = []dataDownload{
@indraoct
indraoct / waitgroup.go
Last active July 20, 2024 16:34
Example WaitGroup
...
func main() {
var (
dDownload []dataDownload
)
wg := sync.WaitGroup{} // initiate wait group
@indraoct
indraoct / DependencyInjection.go
Last active February 23, 2024 04:05
DependencyInjection.go
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/lib/pq"
)
@indraoct
indraoct / main.go
Last active December 13, 2018 08:26
Aplikasi Go Sederhana untuk implementasi Docker
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql" //jangan lupa kasih
"github.com/labstack/echo" // saya pake framework echo sekedar untuk routing
"net/http"
"os"
)
@indraoct
indraoct / utils_test.go
Created June 30, 2018 11:48
Unit test untuk stringutils.go
package stringutils
import (
"testing"
)
func TestSwapCase(t *testing.T) {
input,expected := "Hello, World", "hELLO, wORLD"
result := SwapCase(input)
@indraoct
indraoct / stringutils.go
Last active June 30, 2018 10:48
Fungsi string untuk swap dan reverse
package stringutils
import (
"bytes"
"unicode"
)
func SwapCase(str string) string {
buf := &bytes.Buffer{}
for _,r := range str{
@indraoct
indraoct / WebAPI.v1.0.go
Last active June 9, 2018 18:40
Print Data DB MySQL As a JSON API (Golang)
package main
import (
"database/sql"
"log"
"encoding/json"
_ "github.com/go-sql-driver/mysql"
"net/http"
"github.com/gorilla/mux"
)