Esempio n. 1
1
func main() {
	help := flag.Bool("help", false, "Show usage")
	username := flag.String("u", "", "Specify Github user")
	password := flag.String("p", "", "Specify Github password")

	flag.Usage = func() {
		fmt.Printf("Usage:\n")
		flag.PrintDefaults()
	}
	flag.Parse()

	if *help == true || *username == "" || *password == "" {
		flag.Usage()
		return
	}

	ghc, err := ghclient.NewGithubClient(*username, *password, ghclient.AUTH_USER_PASSWORD)

	gistsc := ghgists.NewGists(ghc)

	res, err := gistsc.GetPublicGistsList()

	jr, err := res.Json()

	fmt.Printf("JSON: %v\nERROR: %v\n", jr, err)

	print("\n\nLOADING NEXT PAGE...\n\n")
	res, err = res.GetNextPage()

	jr, err = res.Json()

	fmt.Printf("JSON: %v\nERROR: %v\n", jr, err)
}
Esempio n. 2
0
func main() {
	help := flag.Bool("help", false, "Show usage")
	username := flag.String("u", "", "Specify Github user")
	password := flag.String("p", "", "Specify Github password")
	userinfo := flag.String("userinfo", "", "Specify another Github user")

	flag.Usage = func() {
		fmt.Printf("Usage:\n")
		flag.PrintDefaults()
	}
	flag.Parse()

	if *help == true || *username == "" || *password == "" || *userinfo == "" {
		flag.Usage()
		return
	}

	ghc, err := ghclient.NewGithubClient(*username, *password,
		ghclient.AUTH_USER_PASSWORD)

	ghusersc := ghusers.NewUsers(ghc)

	res, err := ghusersc.GetUserInfo(*userinfo)

	jr, err := res.Json()

	fmt.Printf("JSON: %v\nHTTP REPLY: %v\nERROR: %v\n", jr, res.RawHttpResponse, err)
}
Esempio n. 3
0
func main() {
	help := flag.Bool("help", false, "Show usage")
	username := flag.String("u", "", "Specify Github user")
	password := flag.String("p", "", "Specify Github password")

	flag.Usage = func() {
		fmt.Printf("Usage:\n")
		flag.PrintDefaults()
	}
	flag.Parse()

	if *help == true || *username == "" || *password == "" {
		flag.Usage()
		return
	}

	ghc, _ := ghclient.NewGithubClient(*username, *password, ghclient.AUTH_USER_PASSWORD)

	ghc_gists := ghgists.NewGists(ghc)

	newGist := ghgists.NewGistDataCreate()
	newGist.Description = "test go create api"
	newGist.Public = false
	newGist.Files["prova1.js"] = ghgists.GistFileContent{Content: "var x=5;"}

	res, _ := ghc_gists.CreateGist(newGist)

	jr, _ := res.Json()
	gist_id := jr.GetString("id")

	data := ghgists.NewGistDataUpdate()
	data.Files["prova1.js"] = ghgists.GistFileContent{Filename: "renamed.js", Content: "var x=5;\nvar y=10;"}

	fmt.Printf("UPDATE DATA: %v\n", data)

	res, _ = ghc_gists.UpdateGist(gist_id, data)

	jr, _ = res.Json()

	fmt.Printf("JSON: %v\n", jr)
	fmt.Printf("RAW: %v\n", res.RawHttpResponse)
}
Esempio n. 4
0
func main() {
	help := flag.Bool("help", false, "Show usage")
	username := flag.String("u", "", "Specify Github user")
	password := flag.String("p", "", "Specify Github password")

	flag.Usage = func() {
		fmt.Printf("Usage:\n")
		flag.PrintDefaults()
	}
	flag.Parse()

	if *help == true || *username == "" || *password == "" {
		flag.Usage()
		return
	}

	ghc, err := ghclient.NewGithubClient(*username, *password, ghclient.AUTH_USER_PASSWORD)

	issuesc := ghissues.NewIssues(ghc)

	res, err := issuesc.GetRepoIssuesList("remogatto", "livegist",
		&ghissues.RepoListOptions{})

	fmt.Printf("RESPONSE: %v\nERROR: %v\n", res.RawHttpResponse, err)

	/*var body []byte = make([]byte, 10000)

	_, err = res.RawHttpResponse.Body.Read(body)*/

	//data, err := ioutil.ReadAll(res.RawHttpResponse.Body)

	jr, err := res.Json()

	/*var jr interface{}

	err := json.Unmarshal(([]byte)("[{\"prova\": 5}]"), &jr)*/

	fmt.Printf("JSON: %v\nERROR: %v\n", jr, err)
}