WWC Belfast
Rebecca Martin
package main
import(
"fmt"
)
func main(){
x := 10
fmt.Println(x)
//don't have to declare an explicit type like int x
}
package main
import(
"fmt"
"log"
"net/http"
"encoding/json" // Go will refuse to compile this file because there is a unused import
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":8080", nil))
}