{"action":"closed","issue":{"url":"https://api.github.com/repos/src-d/go-git/issues/301","repository_url":"https://api.github.com/repos/src-d/go-git","labels_url":"https://api.github.com/repos/src-d/go-git/issues/301/labels{/name}","comments_url":"https://api.github.com/repos/src-d/go-git/issues/301/comments","events_url":"https://api.github.com/repos/src-d/go-git/issues/301/events","html_url":"https://github.com/src-d/go-git/issues/301","id":211953438,"number":301,"title":"Add an example for tags","user":{"login":"KaleoCheng","id":7939352,"avatar_url":"https://avatars1.githubusercontent.com/u/7939352?v=3","gravatar_id":"","url":"https://api.github.com/users/KaleoCheng","html_url":"https://github.com/KaleoCheng","followers_url":"https://api.github.com/users/KaleoCheng/followers","following_url":"https://api.github.com/users/KaleoCheng/following{/other_user}","gists_url":"https://api.github.com/users/KaleoCheng/gists{/gist_id}","starred_url":"https://api.github.com/users/KaleoCheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KaleoCheng/subscriptions","organizations_url":"https://api.github.com/users/KaleoCheng/orgs","repos_url":"https://api.github.com/users/KaleoCheng/repos","events_url":"https://api.github.com/users/KaleoCheng/events{/privacy}","received_events_url":"https://api.github.com/users/KaleoCheng/received_events","type":"User","site_admin":false},"labels":[{"id":276436462,"url":"https://api.github.com/repos/src-d/go-git/labels/invalid","name":"invalid","color":"e6e6e6","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-03-05T13:43:26Z","updated_at":"2017-03-15T16:18:21Z","closed_at":"2017-03-15T16:18:21Z","body":"Hi, \r\n\r\nI used this code but got nothing about tag info. Could you add  an example for this ?\r\n\r\n```shell\r\n// Clones the given repository in memory, creating the remote, the local\r\n// branches and fetching the objects, exactly as:\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"os\"\r\n\r\n\t\"srcd.works/go-git.v4\"\r\n\t\"srcd.works/go-git.v4/plumbing/object\"\r\n)\r\n\r\nfunc main() {\r\n\r\n\tr, err := git.PlainOpen(\"./\")\r\n\tCheckIfError(err)\r\n\r\n\t// ... retrieves the branch pointed by HEAD\r\n\tref, err := r.Head()\r\n\tCheckIfError(err)\r\n\r\n\t// ... retrieves the commit object\r\n\tcommit, err := r.Commit(ref.Hash())\r\n\tCheckIfError(err)\r\n\r\n\theadHash := fmt.Sprintln(commit.Hash)[:8]\r\n\tfmt.Println(headHash)\r\n\r\n\ttagIter, err := r.Tags()\r\n\tCheckIfError(err)\r\n\r\n\tcb := func(t *object.Tag) error {\r\n\t\tfmt.Println(t.Name)\r\n\t\treturn nil\r\n\t}\r\n\terr = tagIter.ForEach(cb)\r\n\tCheckIfError(err)\r\n}\r\n\r\nfunc CheckIfError(err error) {\r\n\tif err == nil {\r\n\t\treturn\r\n\t}\r\n\r\n\tfmt.Printf(\"\\x1b[31;1m%s\\x1b[0m\\n\", fmt.Sprintf(\"error: %s\", err))\r\n\tos.Exit(1)\r\n}\r\n\r\n```\r\n\r\n```shell\r\n$ git tag -l\r\nv0.1.0\r\n$ go run main.go\r\n882be8ca\r\n```"}}
{"actor":{"display_login":"smola"}}