Source file
test/typeparam/issue48318.go
1
2
3
4
5
6
7 package main
8
9 import (
10 "encoding/xml"
11 "fmt"
12 )
13
14 type A[T, U any] struct {
15 Name T `xml:"name"`
16 Data U `xml:"data"`
17 }
18
19 func main() {
20 src := &A[string, int]{Name: "name", Data: 1}
21 data, err := xml.Marshal(src)
22 if err != nil {
23 panic(err)
24 }
25 dst := &A[string, int]{}
26 err = xml.Unmarshal(data, dst)
27 if err != nil {
28 panic(err)
29 }
30 if *src != *dst {
31 panic(fmt.Sprintf("wanted %#v got %#v", src, dst))
32 }
33 }
34
View as plain text