-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
References #29
- Loading branch information
Steve Moyer
committed
Oct 29, 2019
1 parent
f642afe
commit 2994ccb
Showing
5 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ap_test | ||
|
||
import "encoding/json" | ||
|
||
type Real struct { | ||
FieldA string `json:"fieldA"` | ||
AP map[string]json.RawMessage `json:"*"` | ||
} | ||
|
||
type Alias Real | ||
|
||
// alias := struct { | ||
// *Alias | ||
// }{ | ||
// Alias: (*Alias)(u), | ||
// } | ||
|
||
func NewZeroAlias() interface{} { | ||
z := (Alias)(Real{}) | ||
return &z | ||
} | ||
|
||
func NewTestAlias() interface{} { | ||
t := (Alias)(Real{ | ||
FieldA: "Field A", | ||
AP: map[string]json.RawMessage{ | ||
"fieldB": json.RawMessage([]byte("\"Field B\"")), | ||
"fieldC": json.RawMessage([]byte("\"Field C\"")), | ||
}, | ||
}) | ||
return &t | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package ap_test | ||
|
||
import "encoding/json" | ||
|
||
func NewZeroAnonymous() interface{} { | ||
return &struct { | ||
*Alias | ||
}{ | ||
Alias: (*Alias)(&Real{}), | ||
} | ||
} | ||
|
||
func NewTestAnonymous() interface{} { | ||
return struct { | ||
Alias | ||
}{ | ||
Alias: (Alias)(Real{ | ||
FieldA: "Field A", | ||
AP: map[string]json.RawMessage{ | ||
"fieldB": json.RawMessage([]byte("\"Field B\"")), | ||
"fieldC": json.RawMessage([]byte("\"Field C\"")), | ||
}}), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"fieldA":"Field A","fieldB":"Field B","fieldC":"Field C"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"fieldA":"Field A","fieldB":"Field B","fieldC":"Field C"} |