| 1 |
-- Use context.Background -- |
| 2 |
package pkg |
| 3 |
|
| 4 |
import "context" |
| 5 |
|
| 6 |
func tpfn1[T any](ctx context.Context, x T) {} |
| 7 |
func tpfn2[T1, T2 any](ctx context.Context, x T1, y T2) {} |
| 8 |
|
| 9 |
func tpbar() { |
| 10 |
tpfn1[int](context.Background(), 0) //@ diag(`do not pass a nil Context`) |
| 11 |
tpfn1(context.Background(), 0) //@ diag(`do not pass a nil Context`) |
| 12 |
|
| 13 |
tpfn2[int, int](context.Background(), 0, 0) //@ diag(`do not pass a nil Context`) |
| 14 |
tpfn2(context.Background(), 0, 0) //@ diag(`do not pass a nil Context`) |
| 15 |
} |
| 16 |
-- Use context.TODO -- |
| 17 |
package pkg |
| 18 |
|
| 19 |
import "context" |
| 20 |
|
| 21 |
func tpfn1[T any](ctx context.Context, x T) {} |
| 22 |
func tpfn2[T1, T2 any](ctx context.Context, x T1, y T2) {} |
| 23 |
|
| 24 |
func tpbar() { |
| 25 |
tpfn1[int](context.TODO(), 0) //@ diag(`do not pass a nil Context`) |
| 26 |
tpfn1(context.TODO(), 0) //@ diag(`do not pass a nil Context`) |
| 27 |
|
| 28 |
tpfn2[int, int](context.TODO(), 0, 0) //@ diag(`do not pass a nil Context`) |
| 29 |
tpfn2(context.TODO(), 0, 0) //@ diag(`do not pass a nil Context`) |
| 30 |
} |