Skip to content
Sai kiran Krishna murthy edited this page Sep 9, 2018 · 6 revisions

Welcome to the Go-and-Docker-Training wiki!

package main

import (
	"context"
	"fmt"
	"log"
	"net/http"

	"github.com/google/go-github/github"
)

type MetaInfo struct {
	name string
	age  int
}

func githubDemo() {
	client := github.NewClient(nil)
	username := "kiran002"
	filename := "README.md"
	repositories, _, _ := client.Repositories.List(context.Background(), username, nil)
	for i, repo := range repositories {
		_, _, _, err := client.Repositories.GetContents(context.Background(), username, repo.GetName(), filename, nil)
		if err != nil {
			fmt.Printf("%v. %v does not contain a readme.md \n", i+1, repo.GetURL())
		} else {
			ls, _, _ := client.Repositories.ListLanguages(context.Background(), username, repo.GetName())
			fmt.Printf("%v. %v, %v \n", i+1, repo.GetURL(), ls)
		}
	}
}

func main() {
	http.HandleFunc("/", handler)
	http.HandleFunc("/github", githubHandler)
	log.Fatal(http.ListenAndServe(":8080", nil))
}

func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hello world!")
}

func githubHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Hello github!")
}

Clone this wiki locally