{"action":"created","comment":{"url":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/comments/61975927","id":61975927,"diff_hunk":"@@ -1,104 +1,73 @@\n package main\n \n import (\n-\t\"encoding/json\"\n \t\"fmt\"\n-\t\"io/ioutil\"\n-\t\"log\"\n-\t\"net/http\"\n \t\"os\"\n-\t\"os/exec\"\n+\t\"path/filepath\"\n \t\"strings\"\n-)\n-\n-// URL represents path a github repos license\n-var URL = \"https://api.github.com/repos/%s/license?access_token=\" + os.Getenv(\"ACCESS_TOKEN\")\n \n-//types for message to be printed\n-type message struct {\n-\tDependency string\n-\tLicense    string\n-\tLink       string\n-}\n+\t\"github.com/ryanuber/go-license\"\n+)\n \n-// options for response from github\n type response struct {\n-\tHtml_URL string\n-\tLicense  license\n-}\n-\n-type license struct {\n-\tName string\n+\tLicense string\n+\tFile    string\n }\n \n-// uses github api to fetch license based on link generated\n-func getLicense(dependency string, ch chan message) {\n-\turl := formatLink(dependency)\n-\tresp, err := http.Get(url)\n-\tif err != nil {\n-\t\tpanic(err)\n-\t}\n-\n-\tdefer resp.Body.Close()\n-\tbody, err := ioutil.ReadAll(resp.Body)\n-\tif err != nil {\n-\t\tpanic(err)\n-\t}\n-\n-\tcleanBody := &response{}\n-\tif err := json.Unmarshal([]byte(body), &cleanBody); err != nil {\n-\t\tpanic(err)\n-\t}\n-\n-\tlink := cleanBody.Html_URL\n-\tlicense := cleanBody.License.Name\n-\tif link == \"\" {\n-\t\tlink = \"Not Found\"\n-\t}\n-\n-\tch <- message{\n-\t\tDependency: dependency,\n-\t\tLicense:    license,\n-\t\tLink:       link,\n+func getLicense(input chan string, output chan response) {\n+\tfor file := range input {\n+\t\tl, err := license.NewFromFile(file)\n+\t\tsplitFile := strings.Split(file, \"/\")\n+\t\tnewFile := splitFile[1 : len(splitFile)-1]\n+\t\tfile = strings.Join(newFile, \"/\")\n+\t\tif err != nil {\n+\t\t\toutput <- response{File: file, License: err.Error()}\n+\t\t} else {\n+\t\t\toutput <- response{File: file, License: l.Type}\n+\t\t}\n \t}\n }\n \n-// get just the owner and repo and generate github license link\n-func formatLink(link string) string {\n-\tstrippedURL := strings.Split(link, \"/\")\n-\tauthorAndRepo := strings.Join(strippedURL[1:3], \"/\")\n-\tlicenseURL := fmt.Sprintf(URL, authorAndRepo)\n-\treturn licenseURL\n-}\n+func main() {\n+\troot := \"vendor/\"","path":"gdlsc.go","position":90,"original_position":90,"commit_id":"adb3873e45a73869622441e029f9292183d03178","original_commit_id":"adb3873e45a73869622441e029f9292183d03178","user":{"login":"ibrt","id":10485538,"avatar_url":"https://avatars.githubusercontent.com/u/10485538?v=3","gravatar_id":"","url":"https://api.github.com/users/ibrt","html_url":"https://github.com/ibrt","followers_url":"https://api.github.com/users/ibrt/followers","following_url":"https://api.github.com/users/ibrt/following{/other_user}","gists_url":"https://api.github.com/users/ibrt/gists{/gist_id}","starred_url":"https://api.github.com/users/ibrt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibrt/subscriptions","organizations_url":"https://api.github.com/users/ibrt/orgs","repos_url":"https://api.github.com/users/ibrt/repos","events_url":"https://api.github.com/users/ibrt/events{/privacy}","received_events_url":"https://api.github.com/users/ibrt/received_events","type":"User","site_admin":false},"body":"This should be a top level constant.","created_at":"2016-05-03T23:58:52Z","updated_at":"2016-05-03T23:58:52Z","html_url":"https://github.com/andela-ssunday/gdlsc/pull/5#discussion_r61975927","pull_request_url":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/comments/61975927"},"html":{"href":"https://github.com/andela-ssunday/gdlsc/pull/5#discussion_r61975927"},"pull_request":{"href":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/5","id":68793678,"html_url":"https://github.com/andela-ssunday/gdlsc/pull/5","diff_url":"https://github.com/andela-ssunday/gdlsc/pull/5.diff","patch_url":"https://github.com/andela-ssunday/gdlsc/pull/5.patch","issue_url":"https://api.github.com/repos/andela-ssunday/gdlsc/issues/5","number":5,"state":"open","locked":false,"title":"Change how license is gotten","user":{"login":"andela-ssunday","id":544570,"avatar_url":"https://avatars.githubusercontent.com/u/544570?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-ssunday","html_url":"https://github.com/andela-ssunday","followers_url":"https://api.github.com/users/andela-ssunday/followers","following_url":"https://api.github.com/users/andela-ssunday/following{/other_user}","gists_url":"https://api.github.com/users/andela-ssunday/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-ssunday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-ssunday/subscriptions","organizations_url":"https://api.github.com/users/andela-ssunday/orgs","repos_url":"https://api.github.com/users/andela-ssunday/repos","events_url":"https://api.github.com/users/andela-ssunday/events{/privacy}","received_events_url":"https://api.github.com/users/andela-ssunday/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-03T23:51:41Z","updated_at":"2016-05-03T23:58:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aebe7ecde41b9149e300ad59a53671f68416e5c7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/5/commits","review_comments_url":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/5/comments","review_comment_url":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela-ssunday/gdlsc/issues/5/comments","statuses_url":"https://api.github.com/repos/andela-ssunday/gdlsc/statuses/adb3873e45a73869622441e029f9292183d03178","head":{"label":"andela-ssunday:new","ref":"new","sha":"adb3873e45a73869622441e029f9292183d03178","user":{"login":"andela-ssunday","id":544570,"avatar_url":"https://avatars.githubusercontent.com/u/544570?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-ssunday","html_url":"https://github.com/andela-ssunday","followers_url":"https://api.github.com/users/andela-ssunday/followers","following_url":"https://api.github.com/users/andela-ssunday/following{/other_user}","gists_url":"https://api.github.com/users/andela-ssunday/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-ssunday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-ssunday/subscriptions","organizations_url":"https://api.github.com/users/andela-ssunday/orgs","repos_url":"https://api.github.com/users/andela-ssunday/repos","events_url":"https://api.github.com/users/andela-ssunday/events{/privacy}","received_events_url":"https://api.github.com/users/andela-ssunday/received_events","type":"User","site_admin":false},"repo":{"id":57417552,"name":"gdlsc","full_name":"andela-ssunday/gdlsc","owner":{"login":"andela-ssunday","id":544570,"avatar_url":"https://avatars.githubusercontent.com/u/544570?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-ssunday","html_url":"https://github.com/andela-ssunday","followers_url":"https://api.github.com/users/andela-ssunday/followers","following_url":"https://api.github.com/users/andela-ssunday/following{/other_user}","gists_url":"https://api.github.com/users/andela-ssunday/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-ssunday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-ssunday/subscriptions","organizations_url":"https://api.github.com/users/andela-ssunday/orgs","repos_url":"https://api.github.com/users/andela-ssunday/repos","events_url":"https://api.github.com/users/andela-ssunday/events{/privacy}","received_events_url":"https://api.github.com/users/andela-ssunday/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-ssunday/gdlsc","description":"A simple Golang Dependency license checker","fork":false,"url":"https://api.github.com/repos/andela-ssunday/gdlsc","forks_url":"https://api.github.com/repos/andela-ssunday/gdlsc/forks","keys_url":"https://api.github.com/repos/andela-ssunday/gdlsc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-ssunday/gdlsc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-ssunday/gdlsc/teams","hooks_url":"https://api.github.com/repos/andela-ssunday/gdlsc/hooks","issue_events_url":"https://api.github.com/repos/andela-ssunday/gdlsc/issues/events{/number}","events_url":"https://api.github.com/repos/andela-ssunday/gdlsc/events","assignees_url":"https://api.github.com/repos/andela-ssunday/gdlsc/assignees{/user}","branches_url":"https://api.github.com/repos/andela-ssunday/gdlsc/branches{/branch}","tags_url":"https://api.github.com/repos/andela-ssunday/gdlsc/tags","blobs_url":"https://api.github.com/repos/andela-ssunday/gdlsc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-ssunday/gdlsc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-ssunday/gdlsc/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-ssunday/gdlsc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-ssunday/gdlsc/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-ssunday/gdlsc/languages","stargazers_url":"https://api.github.com/repos/andela-ssunday/gdlsc/stargazers","contributors_url":"https://api.github.com/repos/andela-ssunday/gdlsc/contributors","subscribers_url":"https://api.github.com/repos/andela-ssunday/gdlsc/subscribers","subscription_url":"https://api.github.com/repos/andela-ssunday/gdlsc/subscription","commits_url":"https://api.github.com/repos/andela-ssunday/gdlsc/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-ssunday/gdlsc/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-ssunday/gdlsc/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-ssunday/gdlsc/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-ssunday/gdlsc/contents/{+path}","compare_url":"https://api.github.com/repos/andela-ssunday/gdlsc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-ssunday/gdlsc/merges","archive_url":"https://api.github.com/repos/andela-ssunday/gdlsc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-ssunday/gdlsc/downloads","issues_url":"https://api.github.com/repos/andela-ssunday/gdlsc/issues{/number}","pulls_url":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-ssunday/gdlsc/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-ssunday/gdlsc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-ssunday/gdlsc/labels{/name}","releases_url":"https://api.github.com/repos/andela-ssunday/gdlsc/releases{/id}","deployments_url":"https://api.github.com/repos/andela-ssunday/gdlsc/deployments","created_at":"2016-04-29T22:55:34Z","updated_at":"2016-05-02T18:01:41Z","pushed_at":"2016-05-03T23:51:41Z","git_url":"git://github.com/andela-ssunday/gdlsc.git","ssh_url":"git@github.com:andela-ssunday/gdlsc.git","clone_url":"https://github.com/andela-ssunday/gdlsc.git","svn_url":"https://github.com/andela-ssunday/gdlsc","homepage":"","size":8,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"andela-ssunday:master","ref":"master","sha":"b58d3413b24cc755a401f60b6ab3eceb79c8137b","user":{"login":"andela-ssunday","id":544570,"avatar_url":"https://avatars.githubusercontent.com/u/544570?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-ssunday","html_url":"https://github.com/andela-ssunday","followers_url":"https://api.github.com/users/andela-ssunday/followers","following_url":"https://api.github.com/users/andela-ssunday/following{/other_user}","gists_url":"https://api.github.com/users/andela-ssunday/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-ssunday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-ssunday/subscriptions","organizations_url":"https://api.github.com/users/andela-ssunday/orgs","repos_url":"https://api.github.com/users/andela-ssunday/repos","events_url":"https://api.github.com/users/andela-ssunday/events{/privacy}","received_events_url":"https://api.github.com/users/andela-ssunday/received_events","type":"User","site_admin":false},"repo":{"id":57417552,"name":"gdlsc","full_name":"andela-ssunday/gdlsc","owner":{"login":"andela-ssunday","id":544570,"avatar_url":"https://avatars.githubusercontent.com/u/544570?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-ssunday","html_url":"https://github.com/andela-ssunday","followers_url":"https://api.github.com/users/andela-ssunday/followers","following_url":"https://api.github.com/users/andela-ssunday/following{/other_user}","gists_url":"https://api.github.com/users/andela-ssunday/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-ssunday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-ssunday/subscriptions","organizations_url":"https://api.github.com/users/andela-ssunday/orgs","repos_url":"https://api.github.com/users/andela-ssunday/repos","events_url":"https://api.github.com/users/andela-ssunday/events{/privacy}","received_events_url":"https://api.github.com/users/andela-ssunday/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-ssunday/gdlsc","description":"A simple Golang Dependency license checker","fork":false,"url":"https://api.github.com/repos/andela-ssunday/gdlsc","forks_url":"https://api.github.com/repos/andela-ssunday/gdlsc/forks","keys_url":"https://api.github.com/repos/andela-ssunday/gdlsc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-ssunday/gdlsc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-ssunday/gdlsc/teams","hooks_url":"https://api.github.com/repos/andela-ssunday/gdlsc/hooks","issue_events_url":"https://api.github.com/repos/andela-ssunday/gdlsc/issues/events{/number}","events_url":"https://api.github.com/repos/andela-ssunday/gdlsc/events","assignees_url":"https://api.github.com/repos/andela-ssunday/gdlsc/assignees{/user}","branches_url":"https://api.github.com/repos/andela-ssunday/gdlsc/branches{/branch}","tags_url":"https://api.github.com/repos/andela-ssunday/gdlsc/tags","blobs_url":"https://api.github.com/repos/andela-ssunday/gdlsc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-ssunday/gdlsc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-ssunday/gdlsc/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-ssunday/gdlsc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-ssunday/gdlsc/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-ssunday/gdlsc/languages","stargazers_url":"https://api.github.com/repos/andela-ssunday/gdlsc/stargazers","contributors_url":"https://api.github.com/repos/andela-ssunday/gdlsc/contributors","subscribers_url":"https://api.github.com/repos/andela-ssunday/gdlsc/subscribers","subscription_url":"https://api.github.com/repos/andela-ssunday/gdlsc/subscription","commits_url":"https://api.github.com/repos/andela-ssunday/gdlsc/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-ssunday/gdlsc/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-ssunday/gdlsc/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-ssunday/gdlsc/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-ssunday/gdlsc/contents/{+path}","compare_url":"https://api.github.com/repos/andela-ssunday/gdlsc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-ssunday/gdlsc/merges","archive_url":"https://api.github.com/repos/andela-ssunday/gdlsc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-ssunday/gdlsc/downloads","issues_url":"https://api.github.com/repos/andela-ssunday/gdlsc/issues{/number}","pulls_url":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-ssunday/gdlsc/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-ssunday/gdlsc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-ssunday/gdlsc/labels{/name}","releases_url":"https://api.github.com/repos/andela-ssunday/gdlsc/releases{/id}","deployments_url":"https://api.github.com/repos/andela-ssunday/gdlsc/deployments","created_at":"2016-04-29T22:55:34Z","updated_at":"2016-05-02T18:01:41Z","pushed_at":"2016-05-03T23:51:41Z","git_url":"git://github.com/andela-ssunday/gdlsc.git","ssh_url":"git@github.com:andela-ssunday/gdlsc.git","clone_url":"https://github.com/andela-ssunday/gdlsc.git","svn_url":"https://github.com/andela-ssunday/gdlsc","homepage":"","size":8,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/5"},"html":{"href":"https://github.com/andela-ssunday/gdlsc/pull/5"},"issue":{"href":"https://api.github.com/repos/andela-ssunday/gdlsc/issues/5"},"comments":{"href":"https://api.github.com/repos/andela-ssunday/gdlsc/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela-ssunday/gdlsc/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/andela-ssunday/gdlsc/statuses/adb3873e45a73869622441e029f9292183d03178"}}}}