From 393d351826724308297bde21b7fd0982811a097e Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 30 Aug 2013 00:17:43 +0800 Subject: [PATCH] Code fix --- cmd/get.go | 2 +- cmd/serve.go | 2 +- doc/utils.go | 18 ------------------ 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/cmd/get.go b/cmd/get.go index 70a91fdf5..6ae456e8c 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -120,7 +120,7 @@ func runGet(cmd *Command, args []string) { return } - hd, err := doc.GetHomeDir() + hd, err := com.HomeDir() if err != nil { com.ColorLog("[ERRO] Fail to get current user[ %s ]\n", err) return diff --git a/cmd/serve.go b/cmd/serve.go index 5afe15565..be4b18c1a 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -332,7 +332,7 @@ func runningStatus() (int, int, int) { } func startService(listen string) { - homeDir, err := doc.GetHomeDir() + homeDir, err := com.HomeDir() if err != nil { fmt.Println(err) return diff --git a/doc/utils.go b/doc/utils.go index e550e3d5c..ebcbf5d72 100644 --- a/doc/utils.go +++ b/doc/utils.go @@ -16,10 +16,8 @@ package doc import ( "os" - "os/user" "path" "regexp" - "runtime" "strings" "github.com/Unknwon/com" @@ -620,22 +618,6 @@ func IsGoRepoPath(importPath string) bool { return standardPath[importPath] } -func GetHomeDir() (string, error) { - if runtime.GOOS != "windows" { - curUser, err := user.Current() - if err != nil { - return "", err - } - return curUser.HomeDir, nil - } else { - hd, err := com.HomeDir() - if err != nil { - return "", err - } - return hd, nil - } -} - func CheckNodeValue(v string) string { if len(v) == 0 { return ""