package main

import (
"fmt"
"io/ioutil"
"net/http"
"os"
"runtime"
"strings"
"sync"
)

func Get(url string) {
   response, err := http.Get(url)
   if err != nil {
      panic(err)
   }
   defer response.Body.Close()
   if err != nil {
      panic(err)
   }
   body, err := ioutil.ReadAll(response.Body)
   fmt.Println(string(body))
}

//form表单提交方式
func Post(url string, values map[string]string) {
   arr := []string{}
   for k, v := range values {
      str := string(k) + "=" + string(v)
      fmt.Println(str)
      arr = append(arr, str)
   }
   valStr := strings.Join(arr, "&")
   response, err := http.Post(url, "application/x-www-form-urlencoded", strings.NewReader(valStr))
   if err != nil {
      panic(err)
   }
   defer response.Body.Close()
   body, err := ioutil.ReadAll(response.Body)
   if err != nil {
      panic(err)
   }
   fmt.Println(string(body))
}

//测试,根据自己的需要更改
func main() {
var wait = sync.WaitGroup{}
wait.Add(1)
num := runtime.NumCPU()
//GOMAXPROCS 设置可同时执行的最大CPU数
runtime.GOMAXPROCS(num)
val := map[string]string{}
val["a"] = "1"
val["b"] = "2"
val["c"] = "3"
go Post("#34;, val)
val = map[string]string{}
val["a"] = "4"
val["b"] = "5"
val["c"] = "6"
go Post("#34;, val)
wait.Wait()
}