douji3426 2015-11-21 14:51
浏览 6
已采纳

斯堪的纳维亚字符在go-lang go-instagram API绑定中不起作用

Hi I'm trying to wrap my head around what seems to be a problem with multibyte support in this open source library (https://github.com/carbocation/go-instagram/). I am using the code below to retrieve information about the tag blue in swedish. How ever I get an empty array when trying.

fmt.Println("Starting instagram download.")
client := instagram.NewClient(nil)
client.ClientID = "myid"
media, _, _ := client.Tags.RecentMedia("blå", nil)
fmt.Println(media)

I have tried using the api trough the browser and there are several pictures tagged with the tag. I have also tried using the code snippet with tags in English like blue and that returns the latest pictures as well. I would be glad if any one could explain why this might happen. Id like to update the lib so it supports multi-byte but I haven't got the go knowledge required. Is this a go problem or a problem with the library?

Thank you

  • 写回答

1条回答 默认 最新

  • douqian9729 2015-11-21 15:02
    关注

    The problem is in validTagName():

    // Strip out things we know Instagram won't accept. For example, hyphens.
    func validTagName(tagName string) (bool, error) {
        //\W matches any non-word character
        reg, err := regexp.Compile(`\W`)
        if err != nil {
            return false, err
        }
    
        if reg.MatchString(tagName) {
            return false, nil
        }
    
        return true, nil
    }
    

    In Go, \W matches precisely [^0-9A-Za-z_]. This validation check is incorrect.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 求会做山景bo1048b2程序的 直播声卡用
  • ¥15 51单片机与数码管实现电子琴
  • ¥15 h3.6m 人类行为预测论文复现
  • ¥50 wordpress项目注册报失败刷新后其实是成功状态,请求排查原因
  • ¥20 linxu服务器僵尸进程不释放,代码如何修改?
  • ¥15 pycharm激活不成功
  • ¥40 如果update 一个列名为参数的value
  • ¥15 基于51单片机的水位检测系统设计中LCD1602一直不显示
  • ¥15 OCS2安装出现问题,请大家给点意见
  • ¥15 ros小车启动launch文件报错