This is an automated email from the ASF dual-hosted git repository.
wongoo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go-hessian2.git
The following commit(s) were added to refs/heads/master by this push:
new 5e88953 format code using gofmt -l -w . (#333)
5e88953 is described below
commit 5e88953d672c895040e559925559f834cd2203af
Author: 望哥 <[email protected]>
AuthorDate: Sat Oct 29 15:14:10 2022 +0800
format code using gofmt -l -w . (#333)
---
array.go | 2 +-
codec.go | 18 +--
decode.go | 24 +--
java_exception/exception.go | 4 +-
java_exception/interrupted_exception.go | 4 +-
java_exception/interrupted_io_exception.go | 4 +-
java_exception/lambda_conversion_exception.go | 4 +-
java_exception/unmodifiable_class_exception.go | 4 +-
java_util/uuid.go | 2 +-
list.go | 30 ++--
null.go | 4 +-
object.go | 195 +++++++++++++------------
object_test.go | 4 -
pojo.go | 16 +-
14 files changed, 159 insertions(+), 156 deletions(-)
diff --git a/array.go b/array.go
index 1376a7a..30593d5 100644
--- a/array.go
+++ b/array.go
@@ -60,7 +60,7 @@ func (*BooleanArray) JavaClassName() string {
return "[java.lang.Boolean"
}
-//IntegerArray Integer[]
+// IntegerArray Integer[]
type IntegerArray struct {
Values []int32
}
diff --git a/codec.go b/codec.go
index 161bf11..bfe7f10 100644
--- a/codec.go
+++ b/codec.go
@@ -75,7 +75,7 @@ func PackInt8(v int8, b []byte) []byte {
}
// PackInt16 packs int16 to byte array
-//[10].pack('N').bytes => [0, 0, 0, 10]
+// [10].pack('N').bytes => [0, 0, 0, 10]
func PackInt16(v int16) []byte {
var array [2]byte
binary.BigEndian.PutUint16(array[:2], uint16(v))
@@ -83,7 +83,7 @@ func PackInt16(v int16) []byte {
}
// PackUint16 packs uint16 to byte array
-//[10].pack('N').bytes => [0, 0, 0, 10]
+// [10].pack('N').bytes => [0, 0, 0, 10]
func PackUint16(v uint16) []byte {
var array [2]byte
binary.BigEndian.PutUint16(array[:2], v)
@@ -91,7 +91,7 @@ func PackUint16(v uint16) []byte {
}
// PackInt32 packs int32 to byte array
-//[10].pack('N').bytes => [0, 0, 0, 10]
+// [10].pack('N').bytes => [0, 0, 0, 10]
func PackInt32(v int32) []byte {
var array [4]byte
binary.BigEndian.PutUint32(array[:4], uint32(v))
@@ -99,7 +99,7 @@ func PackInt32(v int32) []byte {
}
// PackInt64 packs int64 to byte array
-//[10].pack('q>').bytes => [0, 0, 0, 0, 0, 0, 0, 10]
+// [10].pack('q>').bytes => [0, 0, 0, 0, 0, 0, 0, 10]
func PackInt64(v int64) []byte {
var array [8]byte
binary.BigEndian.PutUint64(array[:8], uint64(v))
@@ -107,7 +107,7 @@ func PackInt64(v int64) []byte {
}
// PackFloat64 packs float64 to byte array
-//[10].pack('G').bytes => [64, 36, 0, 0, 0, 0, 0, 0]
+// [10].pack('G').bytes => [64, 36, 0, 0, 0, 0, 0, 0]
// PackFloat64 invokes go's official math library function Float64bits.
func PackFloat64(v float64) []byte {
var array [8]byte
@@ -116,21 +116,21 @@ func PackFloat64(v float64) []byte {
}
// UnpackInt16 unpacks int16 from byte array
-//(0,2).unpack('n')
+// (0,2).unpack('n')
func UnpackInt16(b []byte) int16 {
arr := b[:2]
return int16(binary.BigEndian.Uint16(arr))
}
// UnpackUint16 unpacks int16 from byte array
-//(0,2).unpack('n')
+// (0,2).unpack('n')
func UnpackUint16(b []byte) uint16 {
arr := b[:2]
return binary.BigEndian.Uint16(arr)
}
// UnpackInt32 unpacks int32 from byte array
-//(0,4).unpack('N')
+// (0,4).unpack('N')
func UnpackInt32(b []byte) int32 {
arr := b[:4]
return int32(binary.BigEndian.Uint32(arr))
@@ -450,7 +450,7 @@ func ConvertSliceValueType(destTyp reflect.Type, v
reflect.Value) (reflect.Value
return sl, nil
}
-//PackPtrInterface pack struct interface to pointer interface
+// PackPtrInterface pack struct interface to pointer interface
func PackPtrInterface(s interface{}, value reflect.Value) interface{} {
vv := reflect.New(reflect.TypeOf(s))
vv.Elem().Set(value)
diff --git a/decode.go b/decode.go
index 0e7932e..13d2a3c 100644
--- a/decode.go
+++ b/decode.go
@@ -89,17 +89,17 @@ func NewDecoderWithSkip(b []byte) *Decoder {
// only for cache pool, before decode Reset should be called.
// For example, with pooling use, will effectively improve performance
//
-// var hessianPool = &sync.Pool{
-// New: func() interface{} {
-// return hessian.NewCheapDecoderWithSkip([]byte{})
-// },
-// }
+// var hessianPool = &sync.Pool{
+// New: func() interface{} {
+// return hessian.NewCheapDecoderWithSkip([]byte{})
+// },
+// }
//
-// decoder := hessianPool.Get().(*hessian.Decoder)
-// fill decode data
-// decoder.Reset(data[:])
-// decode anything ...
-// hessianPool.Put(decoder)
+// decoder := hessianPool.Get().(*hessian.Decoder)
+// fill decode data
+// decoder.Reset(data[:])
+// decode anything ...
+// hessianPool.Put(decoder)
func NewCheapDecoderWithSkip(b []byte) *Decoder {
return &Decoder{reader: bufio.NewReader(bytes.NewReader(b)), isSkip:
true}
}
@@ -324,9 +324,9 @@ func (d *Decoder) DecodeValue() (interface{}, error) {
}
}
-/////////////////////////////////////////
+// ///////////////////////////////////////
// typeRefs
-/////////////////////////////////////////
+// ///////////////////////////////////////
type TypeRefs struct {
typeRefs []reflect.Type
records map[string]bool // record if existing for type
diff --git a/java_exception/exception.go b/java_exception/exception.go
index b8a8866..ca79412 100644
--- a/java_exception/exception.go
+++ b/java_exception/exception.go
@@ -28,9 +28,9 @@ type Throwabler interface {
GetStackTrace() []StackTraceElement
}
-////////////////////////////
+// //////////////////////////
// Throwable
-////////////////////////////
+// //////////////////////////
// Throwable represents an exception of the same name in java
type Throwable struct {
SerialVersionUID int64
diff --git a/java_exception/interrupted_exception.go
b/java_exception/interrupted_exception.go
index 00495b7..c37b9f7 100644
--- a/java_exception/interrupted_exception.go
+++ b/java_exception/interrupted_exception.go
@@ -17,9 +17,9 @@
package java_exception
-////////////////////////////
+// //////////////////////////
// InterruptedException
-////////////////////////////
+// //////////////////////////
// InterruptedException represents an exception of the same name in java
type InterruptedException struct {
SerialVersionUID int64
diff --git a/java_exception/interrupted_io_exception.go
b/java_exception/interrupted_io_exception.go
index 7ecb844..67ffc5a 100644
--- a/java_exception/interrupted_io_exception.go
+++ b/java_exception/interrupted_io_exception.go
@@ -17,9 +17,9 @@
package java_exception
-////////////////////////////
+// //////////////////////////
// InterruptedIOException
-////////////////////////////
+// //////////////////////////
// InterruptedIOException represents an exception of the same name in java
type InterruptedIOException struct {
SerialVersionUID int64
diff --git a/java_exception/lambda_conversion_exception.go
b/java_exception/lambda_conversion_exception.go
index b63e27e..896e9bf 100644
--- a/java_exception/lambda_conversion_exception.go
+++ b/java_exception/lambda_conversion_exception.go
@@ -17,9 +17,9 @@
package java_exception
-////////////////////////////
+// //////////////////////////
// LambdaConversionException
-////////////////////////////
+// //////////////////////////
// LambdaConversionException represents an exception of the same name in java
type LambdaConversionException struct {
SerialVersionUID int64
diff --git a/java_exception/unmodifiable_class_exception.go
b/java_exception/unmodifiable_class_exception.go
index 12755db..abf5ecd 100644
--- a/java_exception/unmodifiable_class_exception.go
+++ b/java_exception/unmodifiable_class_exception.go
@@ -17,9 +17,9 @@
package java_exception
-////////////////////////////
+// //////////////////////////
// UnmodifiableClassException
-////////////////////////////
+// //////////////////////////
// UnmodifiableClassException represents an exception of the same name in java
type UnmodifiableClassException struct {
SerialVersionUID int64
diff --git a/java_util/uuid.go b/java_util/uuid.go
index 844ed8c..62eefe9 100644
--- a/java_util/uuid.go
+++ b/java_util/uuid.go
@@ -26,7 +26,7 @@ func (UUID) JavaClassName() string {
return "java.util.UUID"
}
-//String returns a string object representing this UUID.
+// String returns a string object representing this UUID.
func (uuid UUID) String() string {
return uuid.Value
}
diff --git a/list.go b/list.go
index af60860..c51c01e 100644
--- a/list.go
+++ b/list.go
@@ -243,10 +243,10 @@ func listFixedTypedLenTag(tag byte) bool {
return tag >= _listFixedTypedLenTagMin && tag <=
_listFixedTypedLenTagMax
}
-// Include 3 formats:
-// list ::= x55 type value* 'Z' # variable-length list
-// ::= 'V' type int value* # fixed-length list
-// ::= [x70-77] type value* # fixed-length typed list
+// list include 3 formats:
+// ::= x55 type value* 'Z' # variable-length list
+// ::= 'V' type int value* # fixed-length list
+// ::= [x70-77] type value* # fixed-length typed list
func typedListTag(tag byte) bool {
return tag == BC_LIST_FIXED || tag == BC_LIST_VARIABLE ||
listFixedTypedLenTag(tag)
}
@@ -255,10 +255,10 @@ func listFixedUntypedLenTag(tag byte) bool {
return tag >= _listFixedUntypedLenTagMin && tag <=
_listFixedUntypedLenTagMax
}
-// Include 3 formats:
-// ::= x57 value* 'Z' # variable-length untyped list
-// ::= x58 int value* # fixed-length untyped list
-// ::= [x78-7f] value* # fixed-length untyped list
+// include 3 formats:
+// ::= x57 value* 'Z' # variable-length untyped list
+// ::= x58 int value* # fixed-length untyped list
+// ::= [x78-7f] value* # fixed-length untyped list
func untypedListTag(tag byte) bool {
return tag == BC_LIST_FIXED_UNTYPED || tag == BC_LIST_VARIABLE_UNTYPED
|| listFixedUntypedLenTag(tag)
}
@@ -296,10 +296,10 @@ func (d *Decoder) decList(flag int32) (interface{},
error) {
}
// readTypedList read typed list
-// Include 3 formats:
-// list ::= x55 type value* 'Z' # variable-length list
-// ::= 'V' type int value* # fixed-length list
-// ::= [x70-77] type value* # fixed-length typed list
+// list include 3 formats:
+// ::= x55 type value* 'Z' # variable-length list
+// ::= 'V' type int value* # fixed-length list
+// ::= [x70-77] type value* # fixed-length typed list
func (d *Decoder) readTypedList(tag byte) (interface{}, error) {
listTyp, err := d.decString(TAG_READ)
if err != nil {
@@ -389,9 +389,9 @@ func (d *Decoder) readTypedListValue(length int, listTyp
string, isVariableArr b
// readUntypedList read untyped list
// Include 3 formats:
-// ::= x57 value* 'Z' # variable-length untyped list
-// ::= x58 int value* # fixed-length untyped list
-// ::= [x78-7f] value* # fixed-length untyped list
+// ::= x57 value* 'Z' # variable-length untyped list
+// ::= x58 int value* # fixed-length untyped list
+// ::= [x78-7f] value* # fixed-length untyped list
func (d *Decoder) readUntypedList(tag byte) (interface{}, error) {
isVariableArr := tag == BC_LIST_VARIABLE_UNTYPED
diff --git a/null.go b/null.go
index 8d74d1b..1132308 100644
--- a/null.go
+++ b/null.go
@@ -17,9 +17,9 @@
package hessian
-/////////////////////////////////////////
+// ///////////////////////////////////////
// Null
-/////////////////////////////////////////
+// ///////////////////////////////////////
func EncNull(b []byte) []byte {
return append(b, BC_NULL)
}
diff --git a/object.go b/object.go
index ab46987..3d16043 100644
--- a/object.go
+++ b/object.go
@@ -37,66 +37,74 @@ func typeof(v interface{}) string {
// map/object
/////////////////////////////////////////
-//class-def ::= 'C' string int string* // mandatory type string, the number
of fields, and the field names.
-//object ::= 'O' int value* // class-def id, value list
-// ::= [x60-x6f] value* // class-def id, value list
+// class-def ::= 'C' string int string* // mandatory type string, the number
of fields, and the field names.
+// object ::= 'O' int value* // class-def id, value list
//
-//Object serialization
+// ::= [x60-x6f] value* // class-def id, value list
//
-//class Car {
-// String color;
-// String model;
-//}
+// # Object serialization
//
-//out.writeObject(new Car("red", "corvette"));
-//out.writeObject(new Car("green", "civic"));
+// class Car {
+// String color;
+// String model;
+// }
//
-//---
+// out.writeObject(new Car("red", "corvette"));
+// out.writeObject(new Car("green", "civic"));
//
-//C # object definition (#0)
-// x0b example.Car # type is example.Car
-// x92 # two fields
-// x05 color # color field name
-// x05 model # model field name
+// ---
//
-//O # object def (long form)
-// x90 # object definition #0
-// x03 red # color field value
-// x08 corvette # model field value
+// C # object definition (#0)
//
-//x60 # object def #0 (short form)
-// x05 green # color field value
-// x05 civic # model field value
+// x0b example.Car # type is example.Car
+// x92 # two fields
+// x05 color # color field name
+// x05 model # model field name
//
-//enum Color {
-// RED,
-// GREEN,
-// BLUE,
-//}
+// O # object def (long form)
//
-//out.writeObject(Color.RED);
-//out.writeObject(Color.GREEN);
-//out.writeObject(Color.BLUE);
-//out.writeObject(Color.GREEN);
+// x90 # object definition #0
+// x03 red # color field value
+// x08 corvette # model field value
//
-//---
+// x60 # object def #0 (short form)
//
-//C # class definition #0
-// x0b example.Color # type is example.Color
-// x91 # one field
-// x04 name # enumeration field is "name"
+// x05 green # color field value
+// x05 civic # model field value
//
-//x60 # object #0 (class def #0)
-// x03 RED # RED value
+// enum Color {
+// RED,
+// GREEN,
+// BLUE,
+// }
//
-//x60 # object #1 (class def #0)
-// x90 # object definition ref #0
-// x05 GREEN # GREEN value
+// out.writeObject(Color.RED);
+// out.writeObject(Color.GREEN);
+// out.writeObject(Color.BLUE);
+// out.writeObject(Color.GREEN);
//
-//x60 # object #2 (class def #0)
-// x04 BLUE # BLUE value
+// ---
//
-//x51 x91 # object ref #1, i.e. Color.GREEN
+// C # class definition #0
+//
+// x0b example.Color # type is example.Color
+// x91 # one field
+// x04 name # enumeration field is "name"
+//
+// x60 # object #0 (class def #0)
+//
+// x03 RED # RED value
+//
+// x60 # object #1 (class def #0)
+//
+// x90 # object definition ref #0
+// x05 GREEN # GREEN value
+//
+// x60 # object #2 (class def #0)
+//
+// x04 BLUE # BLUE value
+//
+// x51 x91 # object ref #1, i.e. Color.GREEN
func (e *Encoder) encObject(v interface{}) error {
var (
i int
@@ -289,70 +297,70 @@ func (e *Encoder) encodeMapAsIndexedClass(idx int, m
map[string]interface{}) err
// Object
/////////////////////////////////////////
-//class-def ::= 'C' string int string* // mandatory type string, the number
of fields, and the field names.
-//object ::= 'O' int value* // class-def id, value list
-// ::= [x60-x6f] value* // class-def id, value list
+// class-def ::= 'C' string int string* // mandatory type string, the number
of fields, and the field names.
+// object ::= 'O' int value* // class-def id, value list
+// ::= [x60-x6f] value* // class-def id, value list
//
-//Object serialization
+// Object serialization
//
-//class Car {
-// String color;
-// String model;
-//}
+// class Car {
+// String color;
+// String model;
+// }
//
-//out.writeObject(new Car("red", "corvette"));
-//out.writeObject(new Car("green", "civic"));
+// out.writeObject(new Car("red", "corvette"));
+// out.writeObject(new Car("green", "civic"));
//
-//---
+// ---
//
-//C # object definition (#0)
-// x0b example.Car # type is example.Car
-// x92 # two fields
-// x05 color # color field name
-// x05 model # model field name
+// C # object definition (#0)
+// x0b example.Car # type is example.Car
+// x92 # two fields
+// x05 color # color field name
+// x05 model # model field name
//
-//O # object def (long form)
-// x90 # object definition #0
-// x03 red # color field value
-// x08 corvette # model field value
+// O # object def (long form)
+// x90 # object definition #0
+// x03 red # color field value
+// x08 corvette # model field value
//
-//x60 # object def #0 (short form)
-// x05 green # color field value
-// x05 civic # model field value
+// x60 # object def #0 (short form)
+// x05 green # color field value
+// x05 civic # model field value
//
//
//
//
//
-//enum Color {
-// RED,
-// GREEN,
-// BLUE,
-//}
+// enum Color {
+// RED,
+// GREEN,
+// BLUE,
+// }
//
-//out.writeObject(Color.RED);
-//out.writeObject(Color.GREEN);
-//out.writeObject(Color.BLUE);
-//out.writeObject(Color.GREEN);
+// out.writeObject(Color.RED);
+// out.writeObject(Color.GREEN);
+// out.writeObject(Color.BLUE);
+// out.writeObject(Color.GREEN);
//
-//---
+// ---
//
-//C # class definition #0
-// x0b example.Color # type is example.Color
-// x91 # one field
-// x04 name # enumeration field is "name"
+// C # class definition #0
+// x0b example.Color # type is example.Color
+// x91 # one field
+// x04 name # enumeration field is "name"
//
-//x60 # object #0 (class def #0)
-// x03 RED # RED value
+// x60 # object #0 (class def #0)
+// x03 RED # RED value
//
-//x60 # object #1 (class def #0)
-// x90 # object definition ref #0
-// x05 GREEN # GREEN value
+// x60 # object #1 (class def #0)
+// x90 # object definition ref #0
+// x05 GREEN # GREEN value
//
-//x60 # object #2 (class def #0)
-// x04 BLUE # BLUE value
+// x60 # object #2 (class def #0)
+// x04 BLUE # BLUE value
//
-//x51 x91 # object ref #1, i.e. Color.GREEN
+// x51 x91 # object ref #1, i.e. Color.GREEN
func (d *Decoder) decClassDef() (interface{}, error) {
var (
@@ -416,9 +424,10 @@ func findFieldWithCache(name string, typ reflect.Type)
([]int, *reflect.StructFi
// findField find structField in rType
//
// return
-// indexes []int
-// field reflect.StructField
-// err error
+//
+// indexes []int
+// field reflect.StructField
+// err error
func findField(name string, typ reflect.Type) ([]int, *reflect.StructField,
error) {
for i := 0; i < typ.NumField(); i++ {
// matching tag first, then lowerCamelCase, SameCase, lowerCase
diff --git a/object_test.go b/object_test.go
index 7006849..7dce2a1 100644
--- a/object_test.go
+++ b/object_test.go
@@ -831,7 +831,6 @@ func init() {
RegisterPOJO(new(Mix))
}
-//
// BenchmarkJsonEncode-8 217354 4799 ns/op
832 B/op 15 allocs/op
func BenchmarkJsonEncode(b *testing.B) {
m := Mix{A: int('a'), B: `hello`}
@@ -846,7 +845,6 @@ func BenchmarkJsonEncode(b *testing.B) {
}
}
-//
// BenchmarkEncode-8 211452 5560 ns/op
1771 B/op 51 allocs/op
func BenchmarkEncode(b *testing.B) {
m := Mix{A: int('a'), B: `hello`}
@@ -861,7 +859,6 @@ func BenchmarkEncode(b *testing.B) {
}
}
-//
// BenchmarkJsonDecode-8 123922 8549 ns/op
1776 B/op 51 allocs/op
func BenchmarkJsonDecode(b *testing.B) {
m := Mix{A: int('a'), B: `hello`}
@@ -881,7 +878,6 @@ func BenchmarkJsonDecode(b *testing.B) {
}
}
-//
// BenchmarkDecode-8 104196 10924 ns/op
6424 B/op 98 allocs/op
func BenchmarkDecode(b *testing.B) {
m := Mix{A: int('a'), B: `hello`}
diff --git a/pojo.go b/pojo.go
index c74394f..e50e234 100644
--- a/pojo.go
+++ b/pojo.go
@@ -41,15 +41,13 @@ var tagIdentifier = "hessian"
// SetTagIdentifier for customize struct filed tag of hessian, your can use it
like:
//
-// hessian.SetTagIdentifier("json")
-//
-// type MyUser struct {
-// UserFullName string `json:"user_full_name"`
-// FamilyPhoneNumber string // default convert to => familyPhoneNumber
-// }
-//
-// var user MyUser
-// hessian.NewEncoder().Encode(user)
+// hessian.SetTagIdentifier("json")
+// type MyUser struct {
+// UserFullName string `json:"user_full_name"`
+// FamilyPhoneNumber string // default convert to =>
familyPhoneNumber
+// }
+// var user MyUser
+// hessian.NewEncoder().Encode(user)
func SetTagIdentifier(s string) { tagIdentifier = s }
// POJO interface