FAQ
I have a generic response type that includes a String method. This string
method marshals the response to json.

This allows me to pass a Response value directly to a Writer and have the
value output as json.

I'd love to be able to build a custom response that is composed of this
generic response and be able to use the String method from the generic
response to marshal the composite custom object.

http://play.golang.org/p/hqK9VacFVO

In the playground example, I'd love the output to be:

{"status":"aok","name":"Ken","age":37}

Is that possible through composition or do I need to take a different path
with my approach?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Rob Pike at Apr 30, 2014 at 1:40 am
    http://play.golang.org/p/T_DDeI1M5t

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 29, '14 at 11:46p
activeApr 30, '14 at 1:40a
posts2
users2
websitegolang.org

2 users in discussion

Lostghost: 1 post Rob Pike: 1 post

People

Translate

site design / logo © 2022 Grokbase