Git Product home page Git Product logo

Comments (6)

philhofer avatar philhofer commented on August 21, 2024

Good catch.

from msgp.

ttacon avatar ttacon commented on August 21, 2024

So I mean, I see a couple ways to deal with it.

  1. (Sad but very effective) Reprocess the generate file and pass through imports.Process (golang.org/x/tools/imports). The benefit here is it will catch any embedded pointer field of any type (as long as the type exists on the user's GOPATH). Sadly, it's kinda gross - but it could be as simple as a ~10 line change this way and the speed alteration isn't that bad (I literally reread the generated file, passed it through and wrote back to the file).

  2. Could keep track of fields identified as pointers and try to identify their containing package. The obvious upside is there's no enormous amount of extra IO but the code complexity is raised a decent amount (especially if a decent attempt is made to resolve the package).

Which way would you be leaning?

from msgp.

philhofer avatar philhofer commented on August 21, 2024

I'm fine with (1) for now. We can revisit this if generator time starts getting out of hand. (On my computer, the test file takes 22ms, which is just fine.) FWIW, that's precisely how gofmt-ing of the generated source works.

All in all, I think generating one file requires generating no fewer than 4 AST trees. (Ew.)

from msgp.

ttacon avatar ttacon commented on August 21, 2024

Just pushed one way of doing it in PR #46 . Let me know what you think!

from msgp.

philhofer avatar philhofer commented on August 21, 2024

Formally fixed by #46.

from msgp.

philhofer avatar philhofer commented on August 21, 2024

I've added #47 in case we want to re-visit this.

from msgp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.