douqiu1604 2017-01-27 17:17
浏览 245
已采纳

Redigo的GEOADD命令

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 ?

  • 写回答

1条回答 默认 最新

  • dongxing5525 2017-01-27 17:23
    关注

    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)...)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号