From c03821ff1e278f6a03c17d7fbfc16498559fae40 Mon Sep 17 00:00:00 2001 From: xzyaoi Date: Wed, 19 Sep 2018 21:55:38 +0800 Subject: [PATCH] format code --- cli/config.go | 2 +- cli/handler.go | 14 +++++++------- cli/query.go | 10 +++++----- cli/repository.go | 2 +- cli/service.go | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cli/config.go b/cli/config.go index bfa374393..23e23d381 100644 --- a/cli/config.go +++ b/cli/config.go @@ -57,7 +57,7 @@ func writeConfig(config cvpmConfig) { func getDefaultConfig() cvpmConfig { localPath, _ := homedir.Dir() cvpmPath := filepath.Join(localPath, "cvpm") - var defaultLocal = local{LocalFolder:cvpmPath, Pip:"pip", Python:"python"} + var defaultLocal = local{LocalFolder: cvpmPath, Pip: "pip", Python: "python"} var defaultCVPMConfig = cvpmConfig{Local: defaultLocal, Repositories: []Repository{}} return defaultCVPMConfig } diff --git a/cli/handler.go b/cli/handler.go index ff2350a5a..ccf5b8872 100644 --- a/cli/handler.go +++ b/cli/handler.go @@ -1,17 +1,17 @@ package main import ( + "bufio" + "fmt" "github.com/fatih/color" + "github.com/mitchellh/go-homedir" "github.com/olekukonko/tablewriter" "github.com/urfave/cli" - "github.com/mitchellh/go-homedir" - "fmt" + "log" "os" + "path/filepath" "strconv" "strings" - "bufio" - "path/filepath" - "log" ) func InstallHandler(c *cli.Context) { @@ -87,7 +87,7 @@ func RepoHandler(c *cli.Context) { } } -func ConfigHandler(c* cli.Context) { +func ConfigHandler(c *cli.Context) { homepath, _ := homedir.Dir() configFilePath := filepath.Join(homepath, "cvpm", "config.toml") if _, err := os.Stat(configFilePath); os.IsNotExist(err) { @@ -118,7 +118,7 @@ func ConfigHandler(c* cli.Context) { nextConfig.Local.Python = newPyLocation // Handle Pypi Location fmt.Printf("Pip Location[" + prevConfig.Local.Pip + "]") - newPipLocation, _:= reader.ReadString('\n') + newPipLocation, _ := reader.ReadString('\n') newPipLocation = strings.TrimSpace(newPipLocation) if newPipLocation == "y" || newPipLocation == "Y" || newPipLocation == "Yes" || newPipLocation == "" { newPipLocation = prevConfig.Local.Pip diff --git a/cli/query.go b/cli/query.go index 8cee55232..cc72a5155 100644 --- a/cli/query.go +++ b/cli/query.go @@ -1,10 +1,10 @@ package main import ( - "github.com/mitchellh/go-homedir" "github.com/levigross/grequests" - "os/user" + "github.com/mitchellh/go-homedir" "log" + "os/user" ) func ClientPost(endpoint string, params map[string]string) { @@ -15,8 +15,8 @@ func ClientPost(endpoint string, params map[string]string) { } resp, err := grequests.Post(url, &grequests.RequestOptions{ Headers: map[string]string{"X-Current-User": currentUser.Username}, - JSON: params, - IsAjax: true, + JSON: params, + IsAjax: true, }) if err != nil { log.Fatal(err) @@ -34,7 +34,7 @@ func ClientGet(endpoint string, params map[string]string) { } resp, err := grequests.Get(url, &grequests.RequestOptions{ Headers: map[string]string{"X-Current-Homedir": myhomedir}, - Params: params, + Params: params, }) if err != nil { log.Fatal(err) diff --git a/cli/repository.go b/cli/repository.go index 6b400ad57..68f997445 100644 --- a/cli/repository.go +++ b/cli/repository.go @@ -33,7 +33,7 @@ func readRepos() []Repository { return repos } -func readClientRepos (currentHomedir string) []Repository { +func readClientRepos(currentHomedir string) []Repository { configs := readClientConfig(currentHomedir) repos := configs.Repositories return repos diff --git a/cli/service.go b/cli/service.go index e9c2bce0e..7ff300e39 100644 --- a/cli/service.go +++ b/cli/service.go @@ -3,8 +3,8 @@ package main import ( "github.com/kardianos/service" "log" - "os/user" "os" + "os/user" "runtime" ) @@ -24,7 +24,7 @@ func getCVPMDConfig() *service.Config { currentUser, _ := user.Current() var realUsername string if currentUser.Username == "root" && runtime.GOOS != "windows" { - realUsername = os.Getenv("SUDO_USER") + realUsername = os.Getenv("SUDO_USER") } else { realUsername = currentUser.Username } @@ -33,7 +33,7 @@ func getCVPMDConfig() *service.Config { DisplayName: "CVPM Daemon", Description: "Computer Vision Package Manager[Daemon]", Arguments: []string{"daemon", "run"}, - UserName: realUsername, + UserName: realUsername, } return srvConf }