Source file
test/typeparam/issue50419.go
1
2
3
4
5
6
7
8
9
10 package main
11
12 import (
13 "fmt"
14 )
15
16 func main() {
17 foo := &Foo[string, int]{
18 valueA: "i am a string",
19 valueB: 123,
20 }
21 if got, want := fmt.Sprintln(foo), "i am a string 123\n"; got != want {
22 panic(fmt.Sprintf("got %s, want %s", got, want))
23 }
24 }
25
26 type Foo[T1 any, T2 any] struct {
27 valueA T1
28 valueB T2
29 }
30
31 func (f *Foo[_, _]) String() string {
32 return fmt.Sprintf("%v %v", f.valueA, f.valueB)
33 }
34
View as plain text