Reputation: 8880
I have a simple function which tests whether a string is an integer
func testInt(str string, m map[bool]) int {
_,e := strconv.ParseInt(str, 0, 64);
return m[nil == e] * 7;
}
where the map being passed contains m[true] = 1
, m[false] = 0
. However, when I attempt to run this Go complains
1: syntax error: unexpected )
Either I cannot pass maps around as parameters in this way, or else I am doing this entirely wrong.
Upvotes: 6
Views: 14910
Reputation: 2327
A map
maps keys to values, using the syntax
map[KeyType]ValueType
(see https://blog.golang.org/go-maps-in-action)
In your function, you have not specified a ValueType
, causing this syntax error. It looks like you want a map[bool]int
.
Upvotes: 15