Ai
1 Star 2 Fork 0

xgh2012/api-core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
https.go 809 Bytes
一键复制 编辑 原始数据 按行查看 历史
xgh2012 提交于 2025-10-22 15:36 +08:00 . 添加 百度地图 sn校验计算方法
package coreBiz
import (
"fmt"
"net/url"
)
// HttpBuildQuery 实现类似 PHP 的 http_build_query 功能
func HttpBuildQuery(data map[string]any) string {
values := url.Values{}
for key, val := range data {
switch v := val.(type) {
case string:
values.Add(key, v)
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64:
values.Add(key, fmt.Sprintf("%v", v))
case []string:
for _, item := range v {
values.Add(key, item)
}
case []any:
for _, item := range v {
values.Add(key, fmt.Sprintf("%v", item))
}
case map[string]any:
for subKey, subVal := range v {
values.Add(fmt.Sprintf("%s[%s]", key, subKey), fmt.Sprintf("%v", subVal))
}
default:
values.Add(key, fmt.Sprintf("%v", v))
}
}
return values.Encode()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xgh2012/api-core.git
git@gitee.com:xgh2012/api-core.git
xgh2012
api-core
api-core
v0.0.22

搜索帮助