From 61943804508700b7e4960b2092f9cae502d91eb4 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 23 Aug 2012 13:59:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BC=96=E8=AF=91=E6=88=90ht?= =?UTF-8?q?ml=E7=9A=84go=E6=96=87=E4=BB=B6=EF=BC=8C=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=81=9A=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 build.go diff --git a/build.go b/build.go new file mode 100644 index 00000000..f65254de --- /dev/null +++ b/build.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "github.com/russross/blackfriday" + "io/ioutil" + "os" + "path/filepath" +) + +//定义一个访问者结构体 +type Visitor struct{} + +//定义其碰到目录的时候的行为 +func (v *Visitor) VisitDir(path string, f *os.FileInfo) bool { + fmt.Println(path) + return true +} + +//定义其碰到文件的时候的行为 +func (v *Visitor) VisitFile(path string, f *os.FileInfo) { + fmt.Println(path) + //@todo 如何读取md文件转化为html + input, err := ioutil.ReadAll() + output := blackfriday.MarkdownBasic(input) +} + +func main() { + v := &Visitor{} + errors := make(chan os.Error, 64) //错误消息使用64个缓存,可以随意 + filepath.Walk("./", v, errors) + select { + case err := <-errors: + panic(err) + default: + } +}