mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
gob: add support for maps.
Because maps are mostly a hidden type, they must be implemented using reflection values and will not be as efficient as arrays and slices. R=rsc CC=golang-dev https://golang.org/cl/1127041
This commit is contained in:
parent
46152bb9fe
commit
7861da737e
6 changed files with 254 additions and 43 deletions
|
|
@ -572,6 +572,7 @@ func TestEndToEnd(t *testing.T) {
|
|||
s2 := "string2"
|
||||
type T1 struct {
|
||||
a, b, c int
|
||||
m map[string]*float
|
||||
n *[3]float
|
||||
strs *[2]string
|
||||
int64s *[]int64
|
||||
|
|
@ -579,10 +580,13 @@ func TestEndToEnd(t *testing.T) {
|
|||
y []byte
|
||||
t *T2
|
||||
}
|
||||
pi := 3.14159
|
||||
e := 2.71828
|
||||
t1 := &T1{
|
||||
a: 17,
|
||||
b: 18,
|
||||
c: -5,
|
||||
m: map[string]*float{"pi": &pi, "e": &e},
|
||||
n: &[3]float{1.5, 2.5, 3.5},
|
||||
strs: &[2]string{s1, s2},
|
||||
int64s: &[]int64{77, 89, 123412342134},
|
||||
|
|
@ -921,6 +925,7 @@ type IT0 struct {
|
|||
ignore_g string
|
||||
ignore_h []byte
|
||||
ignore_i *RT1
|
||||
ignore_m map[string]int
|
||||
c float
|
||||
}
|
||||
|
||||
|
|
@ -937,6 +942,7 @@ func TestIgnoredFields(t *testing.T) {
|
|||
it0.ignore_g = "pay no attention"
|
||||
it0.ignore_h = []byte("to the curtain")
|
||||
it0.ignore_i = &RT1{3.1, "hi", 7, "hello"}
|
||||
it0.ignore_m = map[string]int{"one": 1, "two": 2}
|
||||
|
||||
b := new(bytes.Buffer)
|
||||
NewEncoder(b).Encode(it0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue