1.修改build.go文件:为生成的每个html文件设置UTF-8编码,解决浏览器打开文件乱码问题;

2.增加build.sh文件:封装html生成流程,简化命令操作;
 3.增加.gitignore文件:过滤对html、pkg等文件的版本管理。
This commit is contained in:
guiquanz
2013-01-16 17:46:43 +08:00
parent f3ad0bbc60
commit 1f54cf6840
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