It was one of my first thoughts, too. So, just for those who haven't tried it... it does work, technically -
$ gorram net/http Get https://google.com &{200 OK 200 HTTP/2.0 2 0 map[Cache-Control:[private, max-age=0] Content-Type:[text/html; charset=ISO-8859-1] X-Xss-Protection:[1; mode=block] Set-Cookie:[NID=88=E2yqXfl49gKoEJYEtuL4H_FOWxG0OSrOROawAQzestRQCp0dY5cBc-vtLsu-U0ZOO9YF4ZgsuLi_yXc1WoJM-l3p06bGnOghpQiX7UNFdpfO-axDIMQsKkex90z1qSYxIUghrOSUFpPYVhI; expires=Sat, 08-Apr-2017 19:32:14 GMT; path=/; domain=.google.com; HttpOnly] X-Frame-Options:[SAMEORIGIN] Alt-Svc:[quic=":443"; ma=2592000; v="36,35,34,33,32"] Date:[Fri, 07 Oct 2016 19:32:14 GMT] Expires:[-1] P3p:[CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."] Server:[gws]] 0xc420399200 -1 [] false true map[] 0xc4203300f0 0xc4202e6840} However, for useful output, you'd really want to show the body. The problem is that it requires a lot of understanding of how the http.Client works. If you get a 404 from the site, you'll get an empty body and no error... obviously what you'd want is to show the 404, and not just an empty body. I could just hack all that into the generator code.. and maybe that would be worth the wow factor to do it... but in general, I was hoping to avoid type-specific handling and try to be more generic so I don't have to write a new handler for every possible return type. Maybe a workable heuristic would be - if the return type has a field that is an io.Reader, try to read that reader. If it's not empty, show that data, otherwise, just print the struct. That's kind of a hack... I wonder how many other return values would actually follow that pattern. On Friday, October 7, 2016 at 12:58:29 PM UTC-4, mpl wrote: > > out of curiosity, do you envision a way to make something based on > > gorram net/http Get http://foo.org > > "Just Work"? (i.e. it would get you what the user is most likely > interested in: the resp.Body) > > I must admit it's the first thing I tried as it would have been a > gorram fun replacement for curl. > > > On 5 October 2016 at 19:56, Nate Finch <nate....@gmail.com <javascript:>> > wrote: > > Glad you think so :) Suggestions and bugs welcome. It's under active > > development, and I know some things don't work right now (like variadic > > functions), but I'd like to make it work with as wide a swath of go > > functions as I can :) And I think that, since there's such a strong > culture > > of being idiomatic in Go, not to mention implicit interfaces, that we > can > > make a heck of a lot of things Just Workâ˘. > > > > > > On Wednesday, October 5, 2016 at 12:53:24 PM UTC-4, setha...@gmail.com > > wrote: > >> > >> That is... awesome... > >> > >> On Monday, October 3, 2016 at 5:00:34 PM UTC-4, Nate Finch wrote: > >>> > >>> get it via the canonical import path: > >>> > >>> go get npf.io/gorram > >>> > >>> > >>> Code is at https://github.com/natefinch/gorram > >>> > >>> > >>> Still a work in progress, but fun to play around with right now. > >>> > >>> Lets you do things like this: > >>> > >>> > >>> $ echo 12345 | gorram encoding/base64.StdEncoding.EncodeToString > >>> > >>> MTIzNDU2Cg== > >>> > >>> > >>> or > >>> > >>> > >>> $ gorram encoding/json.Indent foo.json "" $'\t' > >>> > >>> { > >>> > >>> "foo" : "bar" > >>> > >>> } > >>> > >>> > >>> or even just > >>> > >>> > >>> $ gorram math.Sqrt 25 > >>> > >>> 5 > >>> > >>> > >>> *does not work with every single function, if there's no obvious way > to > >>> translate a CLI arg to that type. > >>> > >>> > >>> Give it a try and give me some feedback. > > > > -- > > 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...@googlegroups.com <javascript:>. > > For more options, visit https://groups.google.com/d/optout. > -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.