-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Description
When using version v66.0.0
of go-github
, the Go compiler throws a contradictory error when initializing a github.RepositoryContentResponse
struct with a literal for the Commit
field. The error message suggests a type mismatch (cannot use *github.Commit as github.Commit
), even though the struct definition for RepositoryContentResponse
clearly defines the Commit
field as a pointer (*github.Commit
).
This issue does not occur in version v65.0.0
, which compiles correctly with the exact same code. This suggests a potential regression or a subtle breaking change in the type definitions of v66.0.0.
Environment
- Go Version:
go version go1.23.0
- go-github Version:
v66.0.0
Steps to Reproduce
-
Create a new Go project.
-
Add the
go-github
v66 dependency:go get github.com/google/go-github/[email protected]
-
Create a test file (e.g.,
main_test.go
) with the following minimal reproducible code:package main_test import ( "testing" "github.com/google/go-github/v66/github" ) func TestRepositoryContentResponseInitialization(t *testing.T) { // This code fails to compile with go-github v66.0.0 _ = &github.RepositoryContentResponse{ Commit: &github.Commit{SHA: github.String("12345")}, } }
-
Try to build or test the project:
go test
Expected Behavior
The code should compile successfully, as the Commit
field of github.RepositoryContentResponse
is a pointer (*github.Commit
), and we are providing a pointer to a github.Commit
literal.
Actual Behavior
The compiler returns the following error:
project/path
./main_test.go:11:3: cannot use &github.Commit{…} (value of type *github.Commit) as github.Commit value in struct literal
Workaround
Downgrading the library to v65.0.0
resolves the issue completely.
go get github.com/google/go-github/[email protected]
With v65, the same code compiles without any errors.