如何构建特定版本的 Github APIv4 Golang 查询
php小编柚子将为大家介绍如何构建特定版本的 Github APIv4 Golang 查询的方法。Github APIv4是一个强大的查询工具,可以帮助开发者获取并处理Github上的各种数据。然而,有时候我们可能需要获取特定版本的数据,而官方API并没有直接提供这样的功能。在本文中,我们将探讨如何使用Golang编写自定义的查询,以获取特定版本的数据。
问题内容
使用 https://github.com/shurcooL/githubv4,我真的很难为 gh 存储库拉回特定版本。
当有 v3 版本时,以下代码块始终不返回任何内容:
var releaseQ struct { Repository struct { Release struct { Author githubv4.String } `graphql:"release(tagName:$tagName)"` } `graphql:"repository(owner:$repositoryOwner,name:$repositoryName)"` } variables = map[string]interface{}{ "repositoryOwner": githubv4.String("jacobtomlinson"), "repositoryName": githubv4.String("gha-find-replace"), "tagName": githubv4.String("v3"), } err = client.Query(context.Background(), &releaseQ, variables) if err != nil { fmt.Println("Query returned nothing") } fmt.Println("author:", releaseQ.Repository.Release.Author)登录后复制