17
votes
func Match(pattern, name string) (matched bool, err error)

Why does pattern not have to have a type (like pattern string)?

1

1 Answers

24
votes

Per https://tour.golang.org/basics/5:

When two or more consecutive named function parameters share a type, you can omit the type from all but the last.

In this example, we shortened

x int, y int

to

x, y int