Skip to content

Instantly share code, notes, and snippets.

View sonyarianto's full-sized avatar
🙏
Keep learning, stay relevant, relevancy increases value.

Sony AK sonyarianto

🙏
Keep learning, stay relevant, relevancy increases value.
View GitHub Profile
@sonyarianto
sonyarianto / web-routing-goji-mux.go
Created December 5, 2018 09:43
Web routing with Goji mux
package main
import (
"fmt"
"goji.io"
"goji.io/pat"
"net/http"
)
func home(w http.ResponseWriter, r *http.Request) {
@sonyarianto
sonyarianto / index.html
Created December 5, 2018 09:45
Sample of index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Title</title>
</head>
<body>
This is my website body!
</body>
</html>
@sonyarianto
sonyarianto / index2.html
Created December 7, 2018 04:00
Sample of index2.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Title</title>
</head>
<body>
My name is {{.}}.
</body>
</html>
@sonyarianto
sonyarianto / index3.html
Created December 7, 2018 07:44
Sample of index3.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Title</title>
</head>
<body>
My name is {{.Name}} and my age is {{.Age}}.
</body>
</html>
@sonyarianto
sonyarianto / index4.html
Created December 7, 2018 08:11
Sample of index4.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Title</title>
</head>
<body>
<table>
{{range .}}
<tr>
@sonyarianto
sonyarianto / get-local-ip-address.go
Last active December 7, 2018 08:41
Get local IP address
package main
import (
"fmt"
"log"
"net"
)
func main() {
conn, err := net.Dial("udp", "8.8.8.8:80")
@sonyarianto
sonyarianto / template-html.go
Last active December 8, 2018 03:50
Go template code - simple one
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / template-html-2.go
Last active December 8, 2018 03:50
Go template code - pass simple variable
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / template-html-3.go
Last active December 8, 2018 03:51
Go template code - passing multiple variable
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / template-html-4.go
Last active December 8, 2018 03:51
Go template code - passing multiple variable
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {