refactor path things

This commit is contained in:
Liang Ding 2014-10-28 13:22:39 +08:00
parent 3637283168
commit 1c65b74037
3 changed files with 6 additions and 5 deletions

View File

@ -183,7 +183,7 @@ func (*conf) GetExecutableInGOBIN(executable string) string {
executable += ".exe" executable += ".exe"
} }
gopaths := strings.Split(os.Getenv("GOPATH"), PathListSeparator) gopaths := filepath.SplitList(os.Getenv("GOPATH"))
for _, gopath := range gopaths { for _, gopath := range gopaths {
// $GOPATH/bin/$GOOS_$GOARCH/executable // $GOPATH/bin/$GOOS_$GOARCH/executable
@ -280,10 +280,10 @@ func Load() {
// //
// 如果不存在 Workspace 配置所指定的目录路径则创建该目录. // 如果不存在 Workspace 配置所指定的目录路径则创建该目录.
func initWorkspaceDirs() { func initWorkspaceDirs() {
paths := strings.Split(Wide.GetWorkspace(), PathListSeparator) paths := filepath.SplitList(Wide.GetWorkspace())
for _, user := range Wide.Users { for _, user := range Wide.Users {
paths = append(paths, strings.Split(user.GetWorkspace(), PathListSeparator)...) paths = append(paths, filepath.SplitList(user.GetWorkspace())...)
} }

View File

@ -7,6 +7,7 @@ import (
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
@ -124,7 +125,7 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
// glog.Infof("offset: %d", offset) // glog.Infof("offset: %d", offset)
userWorkspace := conf.Wide.GetUserWorkspace(username) userWorkspace := conf.Wide.GetUserWorkspace(username)
workspaces := strings.Split(userWorkspace, conf.PathListSeparator) workspaces := filepath.SplitList(userWorkspace)
libPath := "" libPath := ""
for _, workspace := range workspaces { for _, workspace := range workspaces {
userLib := workspace + conf.PathSeparator + "pkg" + conf.PathSeparator + userLib := workspace + conf.PathSeparator + "pkg" + conf.PathSeparator +

View File

@ -46,7 +46,7 @@ func GetFiles(w http.ResponseWriter, r *http.Request) {
username := session.Values["username"].(string) username := session.Values["username"].(string)
userWorkspace := conf.Wide.GetUserWorkspace(username) userWorkspace := conf.Wide.GetUserWorkspace(username)
workspaces := strings.Split(userWorkspace, conf.PathListSeparator) workspaces := filepath.SplitList(userWorkspace)
root := FileNode{Name: "root", Path: "", IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}} root := FileNode{Name: "root", Path: "", IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}}