package main import ( "encoding/json" "fmt" "log" "net/http" "testing" ) func TestA(T *testing.T) { a := []int{1, 2, 3} b := make([]int, 0) for _, v := range a { b = append(b, v) } log.Println(b) } func TestB(T *testing.T) { CollArr := []string{"company_base", "company_employee", "company_history_name", "company_partner", "annual_report_base", "annual_report_website", "special_enterprise", "special_foundation", "special_gov_unit", "special_hongkong_company", "special_law_office", "special_social_organ", "special_trade_union"} for _, v := range CollArr { switch v { case "company_base": fmt.Println("company_base") case "company_employee": fmt.Println("company_employee") case "special_enterprise", "special_foundation", "special_gov_unit", "special_hongkong_company", "special_law_office", "special_social_organ", "special_trade_union": fmt.Println("special") } } } // TestGetArea 获取行政区划 城市区划代码 func TestGetArea(T *testing.T) { //url := "http://xzqh.mca.gov.cn/getInfo?code=100000&type=2" //省份列表 //url := "http://xzqh.mca.gov.cn/getInfo?code=100000&type=2" //省份列表 //url := "http://xzqh.mca.gov.cn/data/120000_Point.geojson" // url := "http://xzqh.mca.gov.cn/data/quanguo_Point.geojson" // resp, err := http.Get(url) if err != nil { log.Printf("Error %v", err) return } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { log.Printf("Error getting watcher execution status. Status code: %d", resp.StatusCode) return } var result map[string]interface{} err = json.NewDecoder(resp.Body).Decode(&result) if err != nil { log.Printf("Error decoding watcher execution result: %v", err) return } //if len(result) > 0 { // for k, _ := range result { // log.Println(k) // urlD := fmt.Sprintf("http://xzqh.mca.gov.cn/data/%s_Point.geojson", "810000") // resp, err := http.Get(urlD) // if err != nil { // log.Printf("Error %v", err) // return // } // defer resp.Body.Close() // // var resultD map[string]interface{} // err = json.NewDecoder(resp.Body).Decode(&resultD) // if err != nil { // log.Printf("Error decoding watcher execution result: %v", err) // } // // } //} //log.Println(result) }