From 457c6cd3341ef07ff734113ece6860bce564a6bf Mon Sep 17 00:00:00 2001 From: wongoo Date: Thu, 5 Mar 2020 08:38:09 +0800 Subject: [PATCH 1/2] Notice for inheritance --- README.md | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 90ddf82c..47dda903 100644 --- a/README.md +++ b/README.md @@ -46,10 +46,6 @@ So we can maintain a cross language type mapping: | **OTHER COMMON USING TYPE** | | | | **big decimal** | java.math.BigDecimal | github.com/dubbogo/gost/math/big/Decimal | | **big integer** | java.math.BigInteger | github.com/dubbogo/gost/math/big/Integer | -| **Boolean** | Boolean | \*bool (TODO) | -| **Integer** | Integer | \*int32 (TODO)| -| **Long** | Long | \*int64 (TODO)| -| **Double** | Double | \*float64 (TODO) | ## reference @@ -225,3 +221,34 @@ The encoded bytes of the struct `MyUser` is as following: 00000030 4e 75 6d 62 65 72 60 08 75 73 65 72 6e 61 6d 65 |Number`.username| 00000040 0c 30 31 30 2d 31 32 33 34 35 36 37 38 |.010-12345678| ``` + +## Notice for inheritance + +`go-hessian2` support inheritance struct, but the following situations should be avoided. + +### Avoid fields with the same name in multiple parent struct + +The following struct `C` have inherited field `Name`(default from the first parent), +but it's confused in logic. + +```go +type A struct { Name string } +type B struct { Name string } +type C struct { + A + B +} +``` + +### Avoid inheritance for a pointer of struct + +The following definition is valid for golang syntax, +but the parent will be nil when create a new Dog, like `dog := Dog{}`, +which will not happen in java inheritance, +and is also not supported by `go-hessian2`. + +```go +type Dog struct { + *Animal +} +``` \ No newline at end of file From ee95b2de121c512200a7ee9779c58beace6d5f15 Mon Sep 17 00:00:00 2001 From: wongoo Date: Thu, 5 Mar 2020 10:36:06 +0800 Subject: [PATCH 2/2] fix doc --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 47dda903..38632267 100644 --- a/README.md +++ b/README.md @@ -224,9 +224,9 @@ The encoded bytes of the struct `MyUser` is as following: ## Notice for inheritance -`go-hessian2` support inheritance struct, but the following situations should be avoided. +`go-hessian2` supports inheritance struct, but the following situations should be avoided. -### Avoid fields with the same name in multiple parent struct ++ **Avoid fields with the same name in multiple parent struct** The following struct `C` have inherited field `Name`(default from the first parent), but it's confused in logic. @@ -240,7 +240,7 @@ type C struct { } ``` -### Avoid inheritance for a pointer of struct ++ **Avoid inheritance for a pointer of struct** The following definition is valid for golang syntax, but the parent will be nil when create a new Dog, like `dog := Dog{}`,