优化整体

This commit is contained in:
hoteas 2022-03-13 02:00:40 +08:00
parent 5c64580378
commit d6ef790010

View File

@ -7,12 +7,14 @@ import (
"net/url"
)
type BaiduMap struct {
type baiduMap struct {
Ak string
Url string
}
func (that *BaiduMap) Init(Ak string) {
var BaiDuMap = baiduMap{}
func (that *baiduMap) Init(Ak string) {
//"ak=ZeT902EZvVgIoGVWEFK3osUm"
that.Ak = Ak
that.Url = "https://api.map.baidu.com/place/v2/suggestion?output=json" + "&ak=" + Ak
@ -20,7 +22,7 @@ func (that *BaiduMap) Init(Ak string) {
}
// GetPosition 获取定位列表
func (that *BaiduMap) GetPosition(name string, region string) (string, error) {
func (that *baiduMap) GetPosition(name string, region string) (string, error) {
client := &http.Client{}
if region == "" {
@ -50,9 +52,3 @@ func (that *BaiduMap) GetPosition(name string, region string) (string, error) {
return string(body), err
}
var DefaultBaiDuMap BaiduMap
func init() {
DefaultBaiDuMap = BaiduMap{}
}