Sama seperti hari kemarin saya belajar memprogram menggunakan Go Lang. Kali ini saya diajarkan untuk membuat HTML menggunakan bahasa pemrograman yang buat oleh Google. Berikut adalah langkah untuk membuat HTML menggunakan Go Lang:
1. Instal github pada PC kemudian download sql driver seperti contoh dibawah ini
package main
import (
"fmt"
"net/http"
"framework/sys/routing"
"framework/sys/config"
)
func main() {
fmt.Println("Starting server...")
config.RootDirectory = "C:/xampp/htdocs/framework/"
config.ResourcesDirectory = config.RootDirectory+"res"
config.TemplateDirectory = "template/"
config.frameworkDB, _ = config.DBConnect()
routing.Routing()
fmt.Println("Listening on port 8080...")
http.ListenAndServe(":8080", nil)
}
- go get github.com/go-sql-driver/mysql
- go get github.com/gorilla/sessions
- go get github.com/gorilla/context
- go get github.com/gorilla/mux
- go get github.com/gorilla/securecookie
2. Masukkan syntax berikut pada intelliJ
package main
import (
"fmt"
"net/http"
"framework/sys/routing"
"framework/sys/config"
)
func main() {
fmt.Println("Starting server...")
config.RootDirectory = "C:/xampp/htdocs/framework/"
config.ResourcesDirectory = config.RootDirectory+"res"
config.TemplateDirectory = "template/"
config.frameworkDB, _ = config.DBConnect()
routing.Routing()
fmt.Println("Listening on port 8080...")
http.ListenAndServe(":8080", nil)
}
3. Kemudian buat package baru dalam "src" lalu beri nama "mhs.go"
4. Masukkan listing program berikut
package mhs
import (
"net/http"
"framework/sys/mr"
)
func Test (w http.ResponseWriter, r *http.Request){
t,_ := mr.MRenderTemplate("museuminstitution/tes.html");
mr.MExecute(w,t,r)
}
package mhs
import (
"net/http"
"framework/sys/mr"
)
func Test (w http.ResponseWriter, r *http.Request){
t,_ := mr.MRenderTemplate("museuminstitution/tes.html");
mr.MExecute(w,t,r)
}
5. Pada Routing.go tambahkan listing jalan.MuntoiReg("/gnr",mhs.Test) lalu simpan pada C:\xampp\htdocs\gomuntoi\template\museuminstitution
6. Contoh Syntax HTML yang saya buat


