提交 985133f1 编写于 作者: Y yangrui07

cube agent code format

上级 3da70904
......@@ -100,7 +100,7 @@ func handleRest(w http.ResponseWriter, r *http.Request) {
if isJsonDict(s) {
fmt.Fprintln(w, s)
}else {
} else {
logex.Fatalf("invalid json: %v", s)
}
......@@ -128,7 +128,7 @@ func parseHttpKv(r *http.Request) map[string]string {
}
// allow passing hostname for debug
if _, ok := m["hostname"]; !ok{
if _, ok := m["hostname"]; !ok {
ip := r.RemoteAddr[:strings.Index(r.RemoteAddr, ":")]
m["hostname"], _ = getHostname(ip)
}
......
......@@ -2,8 +2,8 @@
package agent
import (
"fmt"
"encoding/json"
"fmt"
)
func initGetHandlers() {
......@@ -13,7 +13,7 @@ func initGetHandlers() {
}
func GetStatus(subpath string, m map[string]string, b []byte) (string, string, error) {
b, err := json.Marshal(BUILTIN_STATUS);
b, err := json.Marshal(BUILTIN_STATUS)
if err != nil {
return quote(""), "", fmt.Errorf("json marshal failed, %v", err)
}
......
......@@ -2,8 +2,8 @@
package agent
import (
"fmt"
"encoding/json"
"fmt"
"github.com/Badangel/logex"
)
......
......@@ -417,7 +417,7 @@ func (work *Work) CheckToReload() bool {
}
func (work *Work) Reload() (err error) {
if (work.Port == "") {
if work.Port == "" {
err = errors.New("Reload with invalid port.")
return
}
......@@ -632,7 +632,7 @@ func (work *Work) Pop() (err error) {
func writeStateFile(dictName string, shardSeq int, service, state string) {
stateFile := fmt.Sprintf(".state_%s_%d", dictName, shardSeq)
if service != "" {
stateFile = stateFile + "_" + service;
stateFile = stateFile + "_" + service
}
cmd := fmt.Sprintf("echo '%s' > %s/state/%s", state, Dir, stateFile)
......@@ -644,7 +644,7 @@ func writeStateFile(dictName string, shardSeq int, service, state string) {
func RemoveStateFile(dictName string, shardSeq int, service string) {
stateFile := fmt.Sprintf(".state_%s_%d", dictName, shardSeq)
if service != "" {
stateFile = stateFile + "_" + service;
stateFile = stateFile + "_" + service
}
cmd := fmt.Sprintf("rm -f %s/state/%s", Dir, stateFile)
......
......@@ -3,8 +3,8 @@ package agent
import (
"errors"
"fmt"
"sync/atomic"
"sync"
"sync/atomic"
)
type (
......
......@@ -3,8 +3,8 @@ package main
import (
"agent"
"fmt"
"github.com/docopt/docopt-go"
"github.com/Badangel/logex"
"github.com/docopt/docopt-go"
"os"
"path/filepath"
"runtime"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册