From ad75e1088b2950bdbb1e035bd658bca6420111d0 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 26 Oct 2014 16:03:19 +0800 Subject: [PATCH] Fix #95 --- editor/formatter.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/editor/formatter.go b/editor/formatter.go index 17f2019..ab49bd2 100644 --- a/editor/formatter.go +++ b/editor/formatter.go @@ -5,8 +5,11 @@ import ( "net/http" "os" "os/exec" + "runtime" + "strings" "github.com/88250/gohtml" + "github.com/b3log/wide/conf" "github.com/b3log/wide/util" "github.com/golang/glog" ) @@ -31,6 +34,12 @@ func GoFmtHandler(w http.ResponseWriter, r *http.Request) { filePath := args["file"].(string) + apiPath := runtime.GOROOT() + conf.PathSeparator + "src" + conf.PathSeparator + "pkg" + if strings.HasPrefix(filePath, apiPath) { // 如果是 Go API 源码文件 + // 忽略修改 + return + } + fout, err := os.Create(filePath) if nil != err {