diff --git a/bytes/replace.go b/bytes/replace.go index a62a161..9826309 100644 --- a/bytes/replace.go +++ b/bytes/replace.go @@ -51,4 +51,3 @@ func Replace(b []byte, src, dest []byte, n int) []byte { } // --------------------------------------------------- - diff --git a/bytes/replace_test.go b/bytes/replace_test.go index bf1925f..6033405 100644 --- a/bytes/replace_test.go +++ b/bytes/replace_test.go @@ -51,4 +51,3 @@ func TestInsertAt(t *testing.T) { t.Fatal("InsertAt failed:", ret) } } - diff --git a/cmdline/cmdline_test.go b/cmdline/cmdline_test.go index 33e2157..929dc36 100644 --- a/cmdline/cmdline_test.go +++ b/cmdline/cmdline_test.go @@ -55,52 +55,52 @@ func TestParse(t *testing.T) { cases := []caseParse{ { - code: ";b", - cmd: []string{"b"}, + code: ";b", + cmd: []string{"b"}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: ";b;abc", - cmd: []string{"b"}, + code: ";b;abc", + cmd: []string{"b"}, codeNext: "abc", - err: nil, + err: nil, }, { - code: "a`b`\\c", - cmd: []string{"a[b]c"}, + code: "a`b`\\c", + cmd: []string{"a[b]c"}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: "a`b`c 'c\\n`123`' \"c\\n\"", - cmd: []string{"a[b]c", "c\\n`123`", "cn"}, + code: "a`b`c 'c\\n`123`' \"c\\n\"", + cmd: []string{"a[b]c", "c\\n`123`", "cn"}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: "auth qboxtest 'mac AccessKey SecretKey'", - cmd: []string{"auth", "qboxtest", "mac AccessKey SecretKey"}, + code: "auth qboxtest 'mac AccessKey SecretKey'", + cmd: []string{"auth", "qboxtest", "mac AccessKey SecretKey"}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: "post http://rs.qiniu.com/delete/`base64 Bucket:Key`", - cmd: []string{"post", "http://rs.qiniu.com/delete/[base64 Bucket:Key]"}, + code: "post http://rs.qiniu.com/delete/`base64 Bucket:Key`", + cmd: []string{"post", "http://rs.qiniu.com/delete/[base64 Bucket:Key]"}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: "post http://rs.qiniu.com/delete `base64 Bucket:Key`", - cmd: []string{"post", "http://rs.qiniu.com/delete", "[base64 Bucket:Key]"}, + code: "post http://rs.qiniu.com/delete `base64 Bucket:Key`", + cmd: []string{"post", "http://rs.qiniu.com/delete", "[base64 Bucket:Key]"}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: "post http://rs.qiniu.com/delete/|base64 Bucket:Key|", - cmd: []string{"post", "http://rs.qiniu.com/delete/[base64 Bucket:Key]"}, + code: "post http://rs.qiniu.com/delete/|base64 Bucket:Key|", + cmd: []string{"post", "http://rs.qiniu.com/delete/[base64 Bucket:Key]"}, codeNext: "", - err: "end of file", + err: "end of file", }, { code: `json '[ @@ -110,43 +110,43 @@ func TestParse(t *testing.T) { {"code": 200}, {"code": 612} ]`}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: "auth qboxtest ```\nmac AccessKey SecretKey```", - cmd: []string{"auth", "qboxtest", "mac AccessKey SecretKey"}, + code: "auth qboxtest ```\nmac AccessKey SecretKey```", + cmd: []string{"auth", "qboxtest", "mac AccessKey SecretKey"}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: "auth qboxtest ===\nmac AccessKey SecretKey```", - cmd: []string{"auth", "qboxtest"}, + code: "auth qboxtest ===\nmac AccessKey SecretKey```", + cmd: []string{"auth", "qboxtest"}, codeNext: "mac AccessKey SecretKey```", - err: "incomplete string, expect ===", + err: "incomplete string, expect ===", }, { - code: "auth qboxtest ===\rmac AccessKey SecretKey===", - cmd: []string{"auth", "qboxtest", "mac AccessKey SecretKey"}, + code: "auth qboxtest ===\rmac AccessKey SecretKey===", + cmd: []string{"auth", "qboxtest", "mac AccessKey SecretKey"}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: "auth qboxtest ===\n\rmac AccessKey SecretKey===", - cmd: []string{"auth", "qboxtest", "\rmac AccessKey SecretKey"}, + code: "auth qboxtest ===\n\rmac AccessKey SecretKey===", + cmd: []string{"auth", "qboxtest", "\rmac AccessKey SecretKey"}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: "auth qboxtest ===\r\n\nmac AccessKey SecretKey===", - cmd: []string{"auth", "qboxtest", "\nmac AccessKey SecretKey"}, + code: "auth qboxtest ===\r\n\nmac AccessKey SecretKey===", + cmd: []string{"auth", "qboxtest", "\nmac AccessKey SecretKey"}, codeNext: "", - err: "end of file", + err: "end of file", }, { - code: "auth qboxtest ===mac AccessKey SecretKey===", - cmd: []string{"auth", "qboxtest", "mac AccessKey SecretKey"}, + code: "auth qboxtest ===mac AccessKey SecretKey===", + cmd: []string{"auth", "qboxtest", "mac AccessKey SecretKey"}, codeNext: "", - err: "end of file", + err: "end of file", }, } @@ -170,4 +170,3 @@ func TestParse(t *testing.T) { } // --------------------------------------------------------------------------- - diff --git a/cmdline/escape.go b/cmdline/escape.go index d0f8b6b..67e89de 100644 --- a/cmdline/escape.go +++ b/cmdline/escape.go @@ -4,7 +4,7 @@ package cmdline const ( escTableBaseChar = '0' - escTableLen = ('z' - escTableBaseChar + 1) + escTableLen = ('z' - escTableBaseChar + 1) ) var escTable = []byte{ @@ -88,11 +88,10 @@ var escTable = []byte{ func defaultEscape(c byte) string { - if c - escTableBaseChar < escTableLen { - c = escTable[c - escTableBaseChar] + if c-escTableBaseChar < escTableLen { + c = escTable[c-escTableBaseChar] } return string(c) } // --------------------------------------------------------------------------- - diff --git a/cmdline/escape_test.go b/cmdline/escape_test.go index 7164216..be1e371 100644 --- a/cmdline/escape_test.go +++ b/cmdline/escape_test.go @@ -38,4 +38,3 @@ func checkEscapeChar(t *testing.T, i, exp int) { } // --------------------------------------------------------------------------- - diff --git a/errors/error_info.go b/errors/error_info.go index 28fe763..828f081 100644 --- a/errors/error_info.go +++ b/errors/error_info.go @@ -61,10 +61,10 @@ func Err(err error) error { // -------------------------------------------------------------------- type ErrorInfo struct { - err error - why error - cmd []interface{} - pc uintptr + err error + why error + cmd []interface{} + pc uintptr } func shortFile(file string) string { @@ -84,7 +84,7 @@ func Info(err error, cmd ...interface{}) *ErrorInfo { } func InfoEx(calldepth int, err error, cmd ...interface{}) *ErrorInfo { - pc, _, _, ok := runtime.Caller(calldepth+1) + pc, _, _, ok := runtime.Caller(calldepth + 1) if !ok { pc = 0 } diff --git a/jsonutil/json_string.go b/jsonutil/json_string.go index 91ef172..8c4cff7 100644 --- a/jsonutil/json_string.go +++ b/jsonutil/json_string.go @@ -12,7 +12,7 @@ import ( func Unmarshal(data string, v interface{}) error { sh := *(*reflect.StringHeader)(unsafe.Pointer(&data)) - arr := (*[1<<30]byte)(unsafe.Pointer(sh.Data)) + arr := (*[1 << 30]byte)(unsafe.Pointer(sh.Data)) return json.Unmarshal(arr[:sh.Len], v) }