Reputation: 25
Here's what i'm trying, using Redigo ("github.com/garyburd/redigo/redis") :
insertPos := []string{"3.361389", "38.115556", "12"}
if _, err := conn.Do("GEOADD", redis.Args{}.Add("geoIndex").AddFlat(&insertPos)...); err != nil {
log.Print(err)
}
==> "ERR wrong number of arguments for 'geoadd' command"
While with the redis-cli this works fine :
GEOADD geoIndex 3.361389 38.115556 12
==> (integer) 1
Other commands works fine, that's just the first time I've to use GEOADD and it clearly doesn't seem to work as I expect it to. Does someone have an idea ?
Upvotes: 2
Views: 514
Reputation: 120979
The easiest way to call this API is:
_, err := conn.Do("GEOADD", "geoIndex", "3.361389", "38.115556", "12")
You can also pass number values:
_, err := conn.Do("GEOADD", "geoIndex", 3.361389, 38.115556, 12)
If you do want to piece the command together, then pass the slice to AddFlat, not a pointer to the slice:
insertPos := []string{"3.361389", "38.115556", "12"}
_, err := conn.Do("GEOADD", redis.Args{}.Add("geoIndex").AddFlat(insertPos)...)
Upvotes: 2