golang urlencode

kccdzz · · 9195 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

u := url.Values{}
    u.Set("a", "1")
    u.Set("b", "2")
    u.Set("data", `{"sessionId":"0bts0W1DWKm70B4UZq3V1h3r2DpsbhDsc2WD","eventId":"8F2qNf0bts0W1DWKm70B4UZq3V1h3r2Dpsbh","androidId":"b22f3d41736f748c","userAgent":"Mozilla/5.0 (Linux; Android 5.1; MI PAD 2 Build/LMY47I; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Safari/537.36","osVersion":"5.1.1","bundleId":"com.brianbaek.popstar","connectionType":"wifi","deviceMake":"Xiaomi","deviceModel":"MI PAD 2","language":"zh_CN","timeZone":"GMT+08:00","campaignId":3261,"mac":"38:a4:ed:fe:99:c8"}`)
    fmt.Println(u.Encode())

返回结果:

a=1&b=2&data=%7B%22sessionId%22%3A%220bts0W1DWKm70B4UZq3V1h3r2DpsbhDsc2WD%22%2C%22eventId%22%3A%228F2qNf0bts0W1DWKm70B4UZq3V1h3r2Dpsbh%22%2C%22androidId%22%3A%22b22f3d41736f748c%22%2C%22userAgent%22%3A%22Mozilla%2F5.0+%28Linux%3B+Android+5.1%3B+MI+PAD+2+Build%2FLMY47I%3B+wv%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Version%2F4.0+Chrome%2F55.0.2883.91+Safari%2F537.36%22%2C%22osVersion%22%3A%225.1.1%22%2C%22bundleId%22%3A%22com.brianbaek.popstar%22%2C%22connectionType%22%3A%22wifi%22%2C%22deviceMake%22%3A%22Xiaomi%22%2C%22deviceModel%22%3A%22MI+PAD+2%22%2C%22language%22%3A%22zh_CN%22%2C%22timeZone%22%3A%22GMT%2B08%3A00%22%2C%22campaignId%22%3A3261%2C%22mac%22%3A%2238%3Aa4%3Aed%3Afe%3A99%3Ac8%22%7D

 


有疑问加站长微信联系(非本文作者)

本文来自:博客园

感谢作者:kccdzz

查看原文:golang urlencode

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

9195 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传