Go HTTP 客户端库:go-rest

jopen 9年前

这是一个简单的工具用于构建更实用的 HTTP 客户端。

已经在Go1.0以上的版本测试过。

package main    import "fmt"  import "github.com/danryan/go-rest/rest"    type githubUser struct {    Login string `json:"login"`    Name  string `json:"name"`  }    func main() {    c, _ := rest.New("https://api.github.com", nil)    c.Header.Set("Content-Type", "application/json")    c.Header.Set("Accept", "application/json")      user := &githubUser{}      _, err := c.Get("users/danryan", user)    if err != nil {      panic(err)    }      fmt.Printf("%s's name is %s\n", user.Login, user.Name)  }

项目主页:http://www.open-open.com/lib/view/home/1414245829653