Merge pull request #144 from guiquanz/master

解决浏览器打开html文件乱码问题等
This commit is contained in:
astaxie
2013-01-16 02:14:33 -08:00
3 changed files with 19 additions and 1 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*~
pkg/*
*.html

View File

@@ -6,8 +6,8 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"regexp"
"strings"
)
// 定义一个访问者结构体
@@ -37,10 +37,14 @@ func (self *Visitor) visit(path string, f os.FileInfo, err error) error {
os.Exit(-1)
}
defer out.Close()
header := "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\"/>\n</head>\n"
footer := "</html>\n"
out.Write([]byte(header))
if _, err = out.Write(output); err != nil {
fmt.Fprintln(os.Stderr, "Error writing output:", err)
os.Exit(-1)
}
out.Write([]byte(footer))
}
}
return nil

10
build.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/sh
rm -f *.html *~
export GOPATH=`pwd`
go get -u github.com/russross/blackfriday
go run build.go