stretchr / objx

Go package for dealing with maps, slices, JSON and other data.
MIT License
691 stars 75 forks source link

Added support for pointer values #84

Closed jeggy closed 5 years ago

jeggy commented 5 years ago

Summary

Added support for retrieving pointer values.

Checklist

hanzei commented 5 years ago

Since objx is mostly used for dealing with JSON data, why do you think this change is needed? It adds a lot more complexity and a much bigger API to the library. I'm not sure if i'm willing to maintain this.

jeggy commented 5 years ago

That's true. I'm not using this with json data, but I'm using it with the flag library.

Sample:

import (
    "flag"
    "github.com/stretchr/objx"
)

func main() {
    clis := objx.Map {
        "message": flag.String("m","default","The message to log out"),
    }
    flag.Parse()
    print("Message: ", *clis.Get("message").PointerStr())
}
hanzei commented 5 years ago

I see that you use case makes sense. But my point still stands: This adds a lot of complexity and I don't want to maintain this. If you provided a PR which introduces this change over the entire codebase, I would merge it. But this is just a fraction of the changes needed to fully support pointers.

jeggy commented 5 years ago

No problem. I haven't really looked through the whole project. I just added whatever I needed and created a pull request.