-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/cgo: cannot define new methods on non-local type in 1.24 #71917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
Comments
see #60725 it's considered a bug as it's not allowed on go type aliases. |
So using instead |
3v1n0
added a commit
to 3v1n0/authd
that referenced
this issue
Feb 24, 2025
By using type alias instead we were getting compile errors in Go 1.24 See: golang/go#71917
3v1n0
added a commit
to ubuntu/authd
that referenced
this issue
Feb 24, 2025
Fix the definition as it wouldn't work in newer go: ``` # github.com/ubuntu/authd/pam/internal/gdm [github.com/ubuntu/authd/pam/internal/gdm.test] ./extension.go:91:12: cannot define new methods on non-local type jsonProtoMessage ./extension.go:106:12: cannot define new methods on non-local type jsonProtoMessage ./extension.go:115:12: cannot define new methods on non-local type jsonProtoMessage ./extension.go:119:12: cannot define new methods on non-local type jsonProtoMessage ./extension.go:123:12: cannot define new methods on non-local type jsonProtoMessage ./extension.go:137:12: cannot define new methods on non-local type jsonProtoMessage FAIL github.com/ubuntu/authd/pam/internal/gdm [build failed] ``` See: golang/go#71917 UDENG-6160
@3v1n0 Sure, that is fine. What is forbidden is defining methods on a C type. With |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go version
go version go1.24.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
We had some code doing:
What did you see happen?
./main.go:16:10: cannot define new methods on non-local type CStruct
What did you expect to see?
This used to work until go 1.23, now it's not allowed anymore.
The text was updated successfully, but these errors were encountered: