Skip to content
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

cmd/cue: JSONMarshaler fields are ignored by cue get go #3495

Open
rustamabd2 opened this issue Oct 11, 2024 · 0 comments
Open

cmd/cue: JSONMarshaler fields are ignored by cue get go #3495

rustamabd2 opened this issue Oct 11, 2024 · 0 comments
Assignees
Labels
NeedsInvestigation Triage Requires triage/attention

Comments

@rustamabd2
Copy link

What version of CUE are you using (cue version)?

Tried with the latest cue master.

$ cue version
cue version v0.0.0-20241010210945-0dd7f6977d97

go version go1.23.2
      -buildmode exe
       -compiler gc
  DefaultGODEBUG asynctimerchan=1,gotypesalias=0,httpservecontentkeepheaders=1,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
             vcs git
    vcs.revision 0dd7f6977d97591ddb165b56005d98cc75d49e93
        vcs.time 2024-10-10T21:09:45Z
    vcs.modified false
cue.lang.version v0.11.0

Does this issue reproduce with the latest stable release?

Yes

What did you do?

exec cue get go --local .
grep field1 x_go_gen.cue
-- cue.mod/module.cue --
module: "example.test"
language: version: "v0.10.0"
-- go.mod --
module test
-- x.go --
package x

type X struct {
    Field1 *Y        `json:"field1"`
    Field2 int    `json:"field2"`
}

type Y struct {
    a int
    //B int
}

func (y *Y) UnmarshalJSON(data []byte) error {
    return nil
}

func (y *Y) MarshalJSON() ([]byte, error) {
    return []byte("true"), nil
}

What did you expect to see?

PASS

What did you see instead?

FAIL: /tmp/testscript2616510834/-/script.txtar:2: no match for `field1` found in x_go_gen.cue

Additional notes

If I uncomment the //B int line, the test passes.

@rustamabd2 rustamabd2 added NeedsInvestigation Triage Requires triage/attention labels Oct 11, 2024
@rogpeppe rogpeppe changed the title encoding/gocode: JSONMarshaler fields are ignored cmd/cue: JSONMarshaler fields are ignored by cue get go Oct 11, 2024
@mvdan mvdan self-assigned this Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Triage Requires triage/attention
Projects
None yet
Development

No branches or pull requests

2 participants