Instantly share code, notes, and snippets.

🙏
Available for hire!

Sony AK sonyarianto

View GitHub Profile
View get-local-ip-address.go
package main
import (
"fmt"
"log"
"net"
)
func main() {
conn, err := net.Dial("udp", "8.8.8.8:80")
@sonyarianto
sonyarianto / template-html-5.go
Last active Dec 8, 2018
Go template code - loop data on template
View template-html-5.go
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / index4.html
Created Dec 7, 2018
Sample of index4.html
View index4.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Title</title>
</head>
<body>
<table>
{{range .}}
<tr>
@sonyarianto
sonyarianto / template-html-4.go
Last active Dec 8, 2018
Go template code - passing multiple variable
View template-html-4.go
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 Dec 8, 2018
Go template code - passing multiple variable
View template-html-3.go
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / index3.html
Created Dec 7, 2018
Sample of index3.html
View 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 / template-html-2.go
Last active Dec 8, 2018
Go template code - pass simple variable
View template-html-2.go
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / index2.html
Created Dec 7, 2018
Sample of index2.html
View index2.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Title</title>
</head>
<body>
My name is {{.}}.
</body>
</html>
@sonyarianto
sonyarianto / template-html.go
Last active Dec 8, 2018
Go template code - simple one
View template-html.go
package main
import (
"github.com/julienschmidt/httprouter"
"html/template"
"log"
"net/http"
)
func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
@sonyarianto
sonyarianto / index.html
Created Dec 5, 2018
Sample of index.html
View index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>My Title</title>
</head>
<body>
This is my website body!
</body>
</html>