Comments (6)
Good catch.
from msgp.
So I mean, I see a couple ways to deal with it.
-
(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).
-
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.
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.
Just pushed one way of doing it in PR #46 . Let me know what you think!
from msgp.
Formally fixed by #46.
from msgp.
I've added #47 in case we want to re-visit this.
from msgp.
Related Issues (20)
- time.Time is not follow the msgpack spec. HOT 6
- `map[int]int` failed to parse
- Compilation error about unused variable in generated *_gen.go file if the struct only has a single property
- Output size configuration
- unnecessary wrapping HOT 2
- new cmd option to generate 1 file per package HOT 1
- Can we use the `json` tag to generate code
- Add Linux and Windows binaries into the release section HOT 2
- Add example for marshaling array of structs into documentation HOT 1
- Can we have a new release tag? HOT 3
- "no definitions in issue185_test.go" HOT 1
- Proposal: Add check via interface for IsEmpty() method, allows treating unknown types as empty HOT 6
- Support for go generics HOT 8
- Add generator option to always produce pointer receivers HOT 3
- Cut v1.1.9 or v1.2.0 release HOT 1
- Extension interface is too generic
- Flattening not working with non-local types HOT 1
- How to using UUID ? (GitHub.com/google/uuid) HOT 1
- Make `shim` directive handle map key HOT 1
- time.Duration type does not work HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msgp.