golang get post

import(

4 "fmt"

5 "net/http"

6 "net/url"

7 "io/IoUtil"

8 )

9

10 func get(){

11

12 response,_:=http.Get("http://xx.jpg")

13 defer response.Body.Close()

14 body,_:=IoUtil.ReadAll(response.Body)

15 fmt.Println(string(body))

16

17 if response.StatusCode == 200 {

18 fmt.Println("ok")

19

20 }else{

21 fmt.Println("error")

22

23 }

24 }

25

26 func post(){

27 //resp,err :=

28

29 http.PostForm("http:///mail",

30 url.Values{"appId": {"1001"},"to": {".com"},

31 "subject":{"golangpost"},"content":{"golangpost test"}})

32

33 }

相关文章

什么是Go的接口? 接口可以说是一种类型,可以粗略的理解为他...
1、Golang指针 在介绍Golang指针隐式间接引用前,先简单说下...
1、概述 1.1 Protocol buffers定义 Protocol buffe...
判断文件是否存在,需要用到"os"包中的两个函数: os.Stat(...
1、编译环境 OS :Loongnix-Server Linux release 8.3 CPU指...
1、概述 Golang是一种强类型语言,虽然在代码中经常看到i:=1...