Comments (4)
@gmlewis thanks for the recommendation; it makes perfect sense!
Although you should probably be using slices instead of creating pointers to arrays, the same bug currently exists for pointers to arrays (not slices) and I think that should definitely be fixed (?).
As for the PR, I'll wait to see what @willnorris thinks before writing the PR and additional test cases.
from go-querystring.
Thanks, @dmlittle, for the report.
First off, I would recommend you carefully analyze why you are using *[]string
in the first place since a slice is a reference type and can itself be nil.
Having said that, however, I see your point and it sounds to me like what you are proposing is a valid solution.
If you decide to go ahead with a PR and @willnorris does not object, just make sure you write your tests to cover as many cases as you can so that we hopefully don't break existing usage.
from go-querystring.
I'll be honest, it's been a really long time since I've done anything but trivial changes to this package, so don't completely remember some of my design ideas.
But it seems that the intent was that pointers to values encode the same as equivalent non-pointer values. I believe that's what
go-querystring/query/encode.go
Lines 220 to 225 in c8c88db
It looks like that block just needs to be moved before
go-querystring/query/encode.go
Line 184 in c8c88db
I honestly don't remember if there was a reason to the current order of that code. Try it and see if any of the tests break?
from go-querystring.
fixed in #42. Confirmed with @dmlittle's sample code in the original comment (thanks for the reproduction case, by the way... that was helpful)
from go-querystring.
Related Issues (20)
- Encoder interface not respected for `interface{}` types HOT 2
- Allow arbitrary delimiter for slice/array type params
- Parsing query strings into a map HOT 3
- Support for Unmarshaler / Marshaler HOT 2
- "query string" for GitHub search HOT 1
- add `decode` method HOT 1
- Slice (Array) pointer does not result in array query values HOT 1
- Is there a way to write a custom marshaller for my custom type? HOT 1
- Unable to handle nil pointers when implementing Encoder HOT 6
- can you please update the tag? HOT 3
- Querystring not adding [] for the array types HOT 1
- Add support for JSON encoding a struct field
- Different behavior on encoding empty slice with any del tag and without HOT 2
- Supporting slices HOT 2
- Structure fields original order messed up HOT 2
- Custom `String` implementations are not respected HOT 7
- Support RFC Specific Encoding HOT 7
- How to encode nested structure by my way? HOT 1
- Support pointer method (*Type)EncodeValues on the Encoder interface HOT 2
- Add support for struct field name casing options
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 go-querystring.