This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h1>Will's Blog!</h1> | |
<p>{{.}}</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
fmt.Printf("Hello World!\n") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
func handlerequest(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hi you accessed post %s", r.URL.Path[1:]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"html/template" | |
"net/http" | |
) | |
func handlerequest(w http.ResponseWriter, r *http.Request) { | |
title := "Hello World!" | |
t := template.New("index.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h1>Will's Blog!</h1> | |
{{range .}} | |
<a href="/{{.File}}"><h2>{{.Title}} ({{.Date}})</h2></a> | |
<p>{{.Summary}}</p> | |
{{end}} | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First post! | |
4th December 2013 | |
This is the summary. | |
This is the main post! | |
# Markdown! | |
*it's* **lovely**! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"html/template" | |
"net/http" | |
"path/filepath" | |
"strings" | |
"io/ioutil" | |
"github.com/russross/blackfriday" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"html/template" | |
"net/http" | |
"path/filepath" | |
"strings" | |
"io/ioutil" | |
"github.com/russross/blackfriday" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Post struct { | |
Title string | |
Date string | |
Summary string | |
Body string | |
File string | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getPosts() []Post{ | |
a := []Post{} | |
files, _ := filepath.Glob("posts/*") | |
for _, f := range files { | |
file := strings.Replace(f, "posts/", "", -1) | |
file = strings.Replace(file, ".md", "", -1) | |
fileread, _ := ioutil.ReadFile(f) | |
lines := strings.Split(string(fileread), "\n") | |
title := string(lines[0]) | |
date := string(lines[1]) |
OlderNewer