Git Product home page Git Product logo

Comments (3)

willnorris avatar willnorris commented on September 27, 2024

what would the signature of the Marshal method that you're proposing look like?

As for unmarshalling, that's outside the initial scope of this library. It could of course be added, but at that point, why not just use http://www.gorillatoolkit.org/pkg/schema ?

from go-querystring.

olebedev avatar olebedev commented on September 27, 2024

Thanks for the tip! I knew about the library but did not pay enough attention. It seems this is what I need.
My idea is to have both operations in a single library and similar agreement for the tags.

It is very simple, of course. And Marshal function is very simple and may look something like this:

// Marshal returns the encoded string of v.
func Marshal(v interface{}) (string, error) {
    var err error
    var values url.Values
    if values, err = Values(v); err != nil {
        return "", err
    }
    return values.Encode(), nil
}

But main work here need to implement the Unmarshal function with the signature:

func Unmarshal(data string, v interface{}) error

But probably there is no need.

from go-querystring.

willnorris avatar willnorris commented on September 27, 2024

as you show above, it's literally one line of code to go from the returned url.Values to a string, so I don't think adding a new Marshal function provides much value.

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.