Not detecting query path:**/*.yaml
Hello I am using "github.com/google/go-github/v54/github" to search codes in my org. While I do search for "org: XX path:**/*.yaml" in github UI it works but while using the below it doesn't
token := os.Getenv("GITHUB_TOKEN")
query := "org:XX path:**/*.yaml"
ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: token},
)
tc := oauth2.NewClient(ctx, ts)
client := github.NewClient(tc)
opts := &github.SearchOptions{
Sort: "score",
Order: "desc",
ListOptions: github.ListOptions{Page: 1, PerPage: 100},
}
result, _, err := client.Search.Code(ctx, query, opts)
fmt.Println(result.CodeResults)
wonder if i am querying it wrong can anyone help? please?
I'm not able to get this to work either. I also tried client.Search.Repositories and that didn't work either.
Going back to the official GitHub v3 REST API documentation, I'm only finding mention of "path:" in the legacy section: https://docs.github.com/en/search-github/searching-on-github/searching-code#search-by-file-location
Could you please contact official GitHub technical support and ask them how you are supposed to add "path:" to their v3 REST API, and report back here?
I'll leave this issue open for you to report back their response. Feel free to point them to this issue to describe the problem. Thank you!
First off, if **/*.yaml is really the path you want to search for, you can get around this problem by using language:yaml instead of path:**/*.yaml. But that trick obviously only works where you are searching for a file extension that happens to identify a language.
To confirm this is a limitation of the GitHub API and not go-github, I reproduced this issue with curl.
$ curl -fG \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
--data-urlencode 'q=your-auth-token-here org:google path:**/*.yaml' \
'https://api.github.com/search/code'
{
"total_count": 0,
"incomplete_results": false,
"items": [
]
}