Git Product home page Git Product logo

Comments (4)

dmlittle avatar dmlittle commented on September 27, 2024 1

@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.

gmlewis avatar gmlewis commented on September 27, 2024

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.

willnorris avatar willnorris commented on September 27, 2024

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

for sv.Kind() == reflect.Ptr {
if sv.IsNil() {
break
}
sv = sv.Elem()
}
is all about.

It looks like that block just needs to be moved before

if sv.Kind() == reflect.Slice || sv.Kind() == reflect.Array {
?
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.

willnorris avatar willnorris commented on September 27, 2024

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)

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.