Skip to content

Instantly share code, notes, and snippets.

View IndianGuru's full-sized avatar

IndianGuru IndianGuru

View GitHub Profile
@IndianGuru
IndianGuru / struct3.go
Created September 4, 2015 04:47
Another struct example
type Student struct {
Name string
}
@IndianGuru
IndianGuru / defineend.txt
Created September 4, 2015 04:51
Define and End in Go
`{{define "T1"}}ONE{{end}}
{{define "T2"}}TWO{{end}}
{{define "T3"}}{{template "T1"}} {{template "T2"}}{{end}}
{{template "T3"}}`
@IndianGuru
IndianGuru / stud_struct.go
Created September 4, 2015 04:56
stud_struct.go
package main
import (
"log"
"os"
"text/template"
)
type Student struct {
//exported field since it begins
@IndianGuru
IndianGuru / person.go
Created September 4, 2015 05:05
person.go
package main
import (
"log"
"os"
"text/template"
)
type Person struct {
Name string
@IndianGuru
IndianGuru / new_person.go
Created September 4, 2015 05:19
new_person.go
package main
import (
"log"
"os"
"text/template"
)
type Person struct {
Name string
@IndianGuru
IndianGuru / layout.html
Created September 4, 2015 08:06
layout.html
{{define "layout"}}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>{{template "title"}}</title>
<link rel="stylesheet" href="/public/stylesheets/dosasite.css">
</head>
<body>
@IndianGuru
IndianGuru / indexnew.html
Created September 4, 2015 08:09
indexnew.html
{{define "title"}}Dosa Diner{{end}}
{{define "body"}}
<h1><img src="public/images/dosa.jpg" alt="Dosa Diner" />Dosa Diner</h1>
<h2>The Restaurant</h2>
<p>The Dosa Diner offers casual lunch and dinner fare in a hip atmosphere.
The menu changes regularly to highlight the freshest ingredients.</p>
<h2>Catering Services</h2>
@IndianGuru
IndianGuru / dosasite.go
Last active September 7, 2015 03:12
New dosasite.go with templates
package main
import (
"fmt"
"html/template"
"log"
"net/http"
"os"
"path"
)
@IndianGuru
IndianGuru / quote.go
Last active September 21, 2015 03:53
Modified quote() in quote.go
// quoteKey returns the key used for all quote entries.
func quoteKey(c context.Context) *datastore.Key {
return datastore.NewKey(c, "Quote", "default_quote", 0, nil)
}
func quote(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
q1 := Quote{
Author: r.FormValue("aut"),
Message: r.FormValue("quo"),
@IndianGuru
IndianGuru / quote.go
Last active September 21, 2015 04:39
Completely modified quote.go
package quote
import (
"fmt"
"html/template"
"net/http"
// Package context defines the Context type
// Do not store Contexts inside a struct type; instead, pass a
// Context explicitly to each function that needs it. The Context