1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- package main
- import (
- "encoding/json"
- "fmt"
- "log"
- "net/http"
- "testing"
- )
- func TestA(T *testing.T) {
- a := []int{1, 2, 3}
- b := a[:2]
- b = append(b, 4)
- fmt.Println(a, b) //[1 2 4],[1 2 4]
- b = append(b, 5)
- fmt.Println(a, b) //[1 2 4],[1 2 4 5]
- b[0] = 10
- fmt.Println(a, b) //[1 2 4],[10 2 4 5]
- }
- 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)
- }
|