Fix #95
This commit is contained in:
parent
280b665b86
commit
ad75e1088b
|
@ -5,8 +5,11 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/88250/gohtml"
|
"github.com/88250/gohtml"
|
||||||
|
"github.com/b3log/wide/conf"
|
||||||
"github.com/b3log/wide/util"
|
"github.com/b3log/wide/util"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
@ -31,6 +34,12 @@ func GoFmtHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
filePath := args["file"].(string)
|
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)
|
fout, err := os.Create(filePath)
|
||||||
|
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
Loading…
Reference in New Issue