blob: a8aeb068999fb52163aac407969a42a9fd360cf8 [file] [log] [blame]
package A1
import (
. "fmt"
myfmt "fmt"
func example(n int) {
x := "foo" + strings.Repeat("\t", n)
// Match, despite named import.
// Match, despite dot import.
// Match: multiple matches in same function are possible.
// No match: wildcarded operand has the wrong type.
myfmt.Errorf("%s", 3)
// No match: function operand doesn't match.
myfmt.Printf("%s", x)
// No match again, dot import.
Printf("%s", x)
// Match.
myfmt.Fprint(os.Stderr, errors.New(x+"foo"))
// No match: though this literally matches the template,
// fmt doesn't resolve to a package here.
var fmt struct{ Errorf func(string, string) }
fmt.Errorf("%s", x)
// Recursive matching:
// Match: both matches are well-typed, so both succeed.
errors.New(errors.New(x + "foo").Error())
// Outer match succeeds, inner doesn't: 3 has wrong type.
errors.New(myfmt.Errorf("%s", 3).Error())
// Inner match succeeds, outer doesn't: the inner replacement
// has the wrong type (error not string).
myfmt.Errorf("%s", errors.New(x+"foo"))