// List returns the names of all the tags in the repository, // eg: ["v1.0.1", "v2.0.0"]. func (c *TagsCollection) List() ([]string, error) { var strC C.git_strarray runtime.LockOSThread() defer runtime.UnlockOSThread() ecode := C.git_tag_list(&strC, c.repo.ptr) if ecode < 0 { return nil, MakeGitError(ecode) } defer C.git_strarray_free(&strC) tags := makeStringsFromCStrings(strC.strings, int(strC.count)) return tags, nil }
func (repo *Repository) TagList() ([]string, error) { var ctags C.git_strarray defer C.git_strarray_free(&ctags) ecode := C.git_tag_list(&ctags, repo.git_repository) if ecode != git_SUCCESS { return nil, gitError() } // TODO: Find a safer way if one exists. var tagsSlice reflect.SliceHeader length := int(ctags.count) tagsSlice.Data = uintptr(unsafe.Pointer(ctags.strings)) tagsSlice.Len = length tagsSlice.Cap = length ctagStrings := *(*[]*C.char)(unsafe.Pointer(&tagsSlice)) tags := make([]string, length) for i := 0; i < len(ctagStrings); i++ { tags[i] = C.GoString(ctagStrings[i]) } return tags, nil }