Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyaoi committed Dec 10, 2018
1 parent 061c84e commit c877c09
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 30 deletions.
18 changes: 9 additions & 9 deletions cli/config.go
@@ -1,5 +1,4 @@
/*
This file handles config related tasks, include:
/* This file handles config related tasks, include:
readConfig()
writeConfig()
validateConfig()
Expand Down Expand Up @@ -87,16 +86,16 @@ func getDefaultConfig() cvpmConfig {
}

func createFolderIfNotExist(folderPath string) {
exist, err := isPathExists(folderPath)
exist, err := isPathExists(folderPath)
if err != nil {
log.Fatal(err)
}
if !exist {
err = os.Mkdir(folderPath, os.ModePerm)
if err != nil {
log.Fatal(err)
}
if !exist {
err = os.Mkdir(folderPath, os.ModePerm)
if err != nil {
log.Fatal(err)
}
}
}
}

func createFileIfNotExist(filePath string) {
Expand Down Expand Up @@ -131,6 +130,7 @@ func validateConfig() {
createFileIfNotExist(cvpmLogPath)
// check if package log file exists
cvpmPackageLogPath := filepath.Join(cvpmPath, "logs", "package.log")
createFileIfNotExist(cvpmPackageLogPath)
}
}

Expand Down
6 changes: 2 additions & 4 deletions cli/daemon.go
@@ -1,8 +1,6 @@
/*
This file handles daemon and services related tasks.
/* This file handles daemon and services related tasks.
By using cvpm daemon install, it will install a system service under current user.
You can uninstall that service by using cvpm daemon uninstall
*/
You can uninstall that service by using cvpm daemon uninstall */
package main

import (
Expand Down
6 changes: 2 additions & 4 deletions cli/handler.go
@@ -1,11 +1,9 @@
/*
This file defines the handlers for different command.
/* This file defines the handlers for different command.
Login
Install
List
Repo
and etc.
*/
and etc. */
package main

import (
Expand Down
6 changes: 3 additions & 3 deletions cli/service.go
Expand Up @@ -24,9 +24,8 @@ func getRunUser() string {
currentUser, _ := user.Current()
if currentUser.Username == "root" && runtime.GOOS != "windows" {
return os.Getenv("SUDO_USER")
} else {
return currentUser.Username
}
return currentUser.Username
}

func getCVPMDConfig() *service.Config {
Expand All @@ -41,6 +40,7 @@ func getCVPMDConfig() *service.Config {
return srvConf
}

// cvpm daemon install -> install the background daemon service
func InstallService() {
srvConfig := getCVPMDConfig()
dae := &sol{}
Expand All @@ -57,7 +57,7 @@ func InstallService() {
log.Fatal(err)
}
}

// cvpm daemon uninstall -> uninstall the background daemon service
func UninstallService() {
srvConfig := getCVPMDConfig()
dae := &sol{}
Expand Down
2 changes: 1 addition & 1 deletion cli/shell.go
Expand Up @@ -162,7 +162,7 @@ func (p *Process) OpenInputStream() (io.WriteCloser, error) {
}
func (p *Process) StreamOutput() *bufio.Scanner {
//pipe both stdout and stderr into the same pipe
//panics if you do streamoutput after proccess starting or
//panics if you do streamoutput after process starting or
//if the output stream is already set
if p.started {
panic("Cant set output stream after starting")
Expand Down
3 changes: 3 additions & 0 deletions cli/template.go
Expand Up @@ -12,6 +12,9 @@ import (
func _getRunnerTpl() string {
var runnerTpl = "https://tpl.cvtron.xyz/runners/runner.tpl"
resp, err := http.Get(runnerTpl)
if err != nil {
log.Fatal(err)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
Expand Down
16 changes: 7 additions & 9 deletions cli/utils.go
Expand Up @@ -39,9 +39,8 @@ func isRoot() bool {
}
if usr.Username == "root" {
return true
} else {
return false
}
}
return false
}

func getDirSizeMB(path string) float64 {
Expand All @@ -62,19 +61,18 @@ func isPortOpen(port string, timeout time.Duration) bool {
if conn != nil {
conn.Close()
return false
} else {
return true
}
return true
}

func findNextOpenPort(port int) string {
var hasFound bool = false
var str_port string
var strPort string
for ; !hasFound; port++ {
str_port = strconv.Itoa(port)
if isPortOpen(str_port, defaultTimeout) {
strPort = strconv.Itoa(port)
if isPortOpen(strPort, defaultTimeout) {
hasFound = true
}
}
return str_port
return strPort
}

0 comments on commit c877c09

Please sign in to comment.