Re: [go-nuts] Best way to add retries to existing library using net/http.Client?

2017-12-11 Thread Kevin Conway
A few of us had a very short discussion on the subject here:
https://groups.google.com/forum/#!topic/golang-nuts/rjYdaFM5OBw

Almost all go code I've seen that requires an HTTP client takes an
`*http.Client` as one of the parameters. This doesn't leave consumers with
many other options than to leverage the `http.RoundTripper` interface that
is consumed via `http.Client.Transport` and implemented by
`http.Transport`. I've seen a great deal of success in using that interface
to implement resiliency features like retries even though the documentation
explicitly forbid using the `http.RoundTripper` for that purpose. My team
has fallen to using a decorator pattern where we define all new
functionality as an `http.RoundTripper` and apply it with a
`func(http.RoundTripper) http.RoundTripper`. Ex:

var client = &http.Client{
  Transport: Retry(TImeout(Log(&http.Transport{}))),
}

On Sun, Dec 10, 2017 at 1:19 PM Alex Buchanan 
wrote:

> I'm considering adding http client retries to an existing library, owned
> by someone else, in order to add resiliency to errors such as http 503. I'd
> like to keep the changes as minimal as possible, with maximum effect, as
> usual. I'm eyeing http.Client.Transport. Possibly I could use that to wrap
> the DefaultTransport, intercept responses, check the code against some
> rules, and retry on failure.
>
> Am I on the right track here?
>
> Thanks,
> Alex
>
> --
> 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.
>

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


[go-nuts] Re: GoLang dependency -> dep installation Issue , Burrow golang tool issues

2017-12-11 Thread Arun Singh
*No* I have not been able to install the dep tool, I used this dep 
 link to install tool.

~
Regards
Arun

If you're interested in hacking on dep, you can install via go get:

go get -u github.com/golang/dep/cmd/dep



On Saturday, 9 December 2017 01:45:02 UTC+5:30, Ondrej Fabry wrote:
>
> I am not sure what is your problem exactly. Did you follow the readme and 
> actually installed dep tool?

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


[go-nuts] XML Pretty Print

2017-12-11 Thread Mandolyte
At my previous company I had a Go program that would take any XML document 
and output it as XML in a nicer human readable format, i.e., pretty 
printed. I've trying to find it again, but my searches have not turned up 
any. Perhaps I had written myself, but I didn't think so.

Does anyone have a link to one?

Thanks in advance,
Cecil

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


[go-nuts] liteide x33.1 released

2017-12-11 Thread visualfc
Hi all.
LiteIDE x33.1 released!
This version adjust menu, add tools menu, enable edit menu for anytime, renamed 
part of the tool window. Add quick open command action 
(ctrl+shift+p/command+shift+p). Change  quick open files use thread for fast 
and cancel. Integrated gomodifytags and add gui dialog for support gomodifytags 
all options.

Links

LiteIDE Home http://liteide.org
LiteIDE Source code https://github.com/visualfc/liteide
Gotools Source code https://github.com/visualfc/gotools
Release downloads
http://sourceforge.net/projects/liteide/files
https://github.com/visualfc/liteide/releases/latest

### 2017.12.12 Ver X33.1
* LiteIDE
* support quick open command
* support gomodifytags
* fix libpng warning on qt5 build 
* LiteApp
* add tools menu for quick open actions
* standard and rename tool window title
* enable edit menu anytime, fix edit menu disable on editor lost focus.
* fix editor load large file bad_alloc recover
* LiteEnv
* add select env to tools menu  
* LiteEditor
* check and not open large file
* fix edit hide edit sub menu 'setup' on macos
* LiteFind
* fix find editor replace all wrap around* GolangEdit
* Integrated [gomodifytags](https://github.com/fatih/gomodifytags) and 
gui tools support gomodifytags all options
* QuickOpen
* add quick open command action (ctrl+shift+p/command+shift+p)
* quickopenfiles use thread for fast and cancel
* fix quickopenfile cancel loading for esc or liteapp quit

Sent from Gmail

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


re:[go-nuts] liteide x33.1 released

2017-12-11 Thread visualfc
liteide x33.1 release integrated gocode and gotools build on go1.10beta1 and 
support go1.9 / go1.10beta1 or lower

Sent from Gmail

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


[go-nuts] Re: XML Pretty Print

2017-12-11 Thread C Banning
https://godoc.org/github.com/clbanning/mxj#BeautifyXml does that - but 
you've got to lug around a pretty large package just for that functionality.

On Monday, December 11, 2017 at 8:12:38 AM UTC-7, Mandolyte wrote:
>
> At my previous company I had a Go program that would take any XML document 
> and output it as XML in a nicer human readable format, i.e., pretty 
> printed. I've trying to find it again, but my searches have not turned up 
> any. Perhaps I had written myself, but I didn't think so.
>
> Does anyone have a link to one?
>
> Thanks in advance,
> Cecil
>

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


[go-nuts] os.Stat and os.IsNotExist on Windows

2017-12-11 Thread Petr Shevtsov
Greetings, gophers!

I've spotted rather strange behavior of os.IsNotExist on Windows.

This snippet[1]

s := "http://example.com/";
fi, err := os.Stat(s)
if os.IsNotExist(err) {
fmt.Println("Not a file")
return
}
mode := fi.Mode()
if mode.IsRegular() {
fmt.Println("File")
}

works perfectly on Linux but panics on Windows.

This happens because of os.Stat returns an error "CreateFile 
http://example.com/: The filename, directory name, or volume label syntax 
is incorrect." (errno 123[2]) for such input, but os.IsNotExist(err) 
returns false.

Is this a bug in os.IsNotExist[3] or such behavior is intentional?


[1] https://play.golang.org/p/oC-ecJLBso
[2] 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx#error_invalid_name
[3] actually in isNotExit function in os/error_windows.go

--
Petr Shevtsov

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


[go-nuts] Re: Why are can't struct field types not be used as types

2017-12-11 Thread anmol via golang-nuts
OP said he does not want to litter his code with helper types.

On Sunday, December 10, 2017 at 1:30:33 PM UTC-5, Kevin Malachowski wrote:
>
> Why not name the inner type? https://play.golang.org/p/8hyMLUVbCp

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


[go-nuts] Re: XML Pretty Print

2017-12-11 Thread C Banning
Well, pretty much all the functionality you need is in 
clbanning/mxj/xmlseq.go ... so you could cut it out and clean it up a bit.

On Monday, December 11, 2017 at 9:03:12 AM UTC-7, C Banning wrote:
>
> https://godoc.org/github.com/clbanning/mxj#BeautifyXml does that - but 
> you've got to lug around a pretty large package just for that functionality.
>
> On Monday, December 11, 2017 at 8:12:38 AM UTC-7, Mandolyte wrote:
>>
>> At my previous company I had a Go program that would take any XML 
>> document and output it as XML in a nicer human readable format, i.e., 
>> pretty printed. I've trying to find it again, but my searches have not 
>> turned up any. Perhaps I had written myself, but I didn't think so.
>>
>> Does anyone have a link to one?
>>
>> Thanks in advance,
>> Cecil
>>
>

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


Re: [go-nuts] XML Pretty Print

2017-12-11 Thread Sam Whited
On Mon, Dec 11, 2017, at 09:12, Mandolyte wrote:
> At my previous company I had a Go program that would take any XML
> document 
> and output it as XML in a nicer human readable format, i.e., pretty 
> printed. I've trying to find it again, but my searches have not turned up 
> any. Perhaps I had written myself, but I didn't think so.
> 
> Does anyone have a link to one?

My xmlstream package contains a formatting transformer that might do
what you want:

https://godoc.org/mellium.im/xmlstream

Note that this was written to test some changes for Go 1.10 and it may
only build there.

—Sam

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


Re: [go-nuts] os.Stat and os.IsNotExist on Windows

2017-12-11 Thread Ian Lance Taylor
On Mon, Dec 11, 2017 at 1:27 AM, Petr Shevtsov  wrote:
>
> I've spotted rather strange behavior of os.IsNotExist on Windows.
>
> This snippet[1]
>
> s := "http://example.com/";
> fi, err := os.Stat(s)
> if os.IsNotExist(err) {
> fmt.Println("Not a file")
> return
> }
> mode := fi.Mode()
> if mode.IsRegular() {
> fmt.Println("File")
> }
>
> works perfectly on Linux but panics on Windows.
>
> This happens because of os.Stat returns an error "CreateFile
> http://example.com/: The filename, directory name, or volume label syntax is
> incorrect." (errno 123[2]) for such input, but os.IsNotExist(err) returns
> false.
>
> Is this a bug in os.IsNotExist[3] or such behavior is intentional?

This sounds like a bug, although it may not be easy to fix.  Please
open an bug report at https://golang.org/issue.  Thanks.

Ian

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


Re: [go-nuts] Breaking change: reflect.StructOf: field 0 has no name

2017-12-11 Thread mihai
Is there any reason why this breaking change is not mentioned in any of the 
release notes? 

On Monday, December 11, 2017 at 8:22:28 AM UTC+2, Ian Lance Taylor wrote:
>
> On Sun, Dec 10, 2017 at 8:46 AM,  > wrote: 
> > 
> > I had some code that I didn't touch for a while and now it seems it's 
> > broken. It panics with `reflect.StructOf: field 0 has no name` at 
> runtime. 
> > Wasn't Go supposed to have some sort of compatibility promise? 
> > 
> > After a while I've found this[1]  issue which seems to be the reason why 
> my 
> > program panics now and my question is why is a struct field without a 
> name 
> > invalid ? Anonymous fields are supposed to have no field names, right? 
> > 
> >  https://github.com/golang/go/issues/20600 
>
> Yes, unfortunately we had to change the way that it worked.  To make 
> an anonymous field, set the name to the type name and set Anonymous to 
> true. 
>
> Ian 
>

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


Re: [go-nuts] Best way to add retries to existing library using net/http.Client?

2017-12-11 Thread Alex Buchanan
It would help a lot if someone could describe *why* interpreting 
higher-level protocol details (auth, redirects, cookies) is a bad thing. 
Also, retries aren't necessarily part of that "higher-level protocol" list, 
but I don't understand well enough to decide.

The reality is, I'm very likely going to use the transport for redirects 
anyway.

On Monday, December 11, 2017 at 1:26:05 AM UTC-8, Kevin Conway wrote:
>
> A few of us had a very short discussion on the subject here: 
> https://groups.google.com/forum/#!topic/golang-nuts/rjYdaFM5OBw
>
> Almost all go code I've seen that requires an HTTP client takes an 
> `*http.Client` as one of the parameters. This doesn't leave consumers with 
> many other options than to leverage the `http.RoundTripper` interface that 
> is consumed via `http.Client.Transport` and implemented by 
> `http.Transport`. I've seen a great deal of success in using that interface 
> to implement resiliency features like retries even though the documentation 
> explicitly forbid using the `http.RoundTripper` for that purpose. My team 
> has fallen to using a decorator pattern where we define all new 
> functionality as an `http.RoundTripper` and apply it with a 
> `func(http.RoundTripper) http.RoundTripper`. Ex:
>
> var client = &http.Client{
>   Transport: Retry(TImeout(Log(&http.Transport{}))),
> }
>
> On Sun, Dec 10, 2017 at 1:19 PM Alex Buchanan  > wrote:
>
>> I'm considering adding http client retries to an existing library, owned 
>> by someone else, in order to add resiliency to errors such as http 503. I'd 
>> like to keep the changes as minimal as possible, with maximum effect, as 
>> usual. I'm eyeing http.Client.Transport. Possibly I could use that to wrap 
>> the DefaultTransport, intercept responses, check the code against some 
>> rules, and retry on failure.
>>
>> Am I on the right track here?
>>
>> Thanks,
>> Alex 
>>
>> -- 
>> 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 .
>> 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.


Re: [go-nuts] Breaking change: reflect.StructOf: field 0 has no name

2017-12-11 Thread Ian Lance Taylor
On Mon, Dec 11, 2017 at 11:23 AM,   wrote:
> Is there any reason why this breaking change is not mentioned in any of the
> release notes?

The original code did not document how to create embedded fields, and
the support that it did have did not work correctly (it did not set
the package path correctly).  So I think we just assumed that we were
only breaking people who were relying on undocumented and incorrect
behavior, and therefore nothing special needed to be said in the
release notes.  Sorry for the trouble.  See
https://golang.org/issue/18780.

Ian

> On Monday, December 11, 2017 at 8:22:28 AM UTC+2, Ian Lance Taylor wrote:
>>
>> On Sun, Dec 10, 2017 at 8:46 AM,   wrote:
>> >
>> > I had some code that I didn't touch for a while and now it seems it's
>> > broken. It panics with `reflect.StructOf: field 0 has no name` at
>> > runtime.
>> > Wasn't Go supposed to have some sort of compatibility promise?
>> >
>> > After a while I've found this[1]  issue which seems to be the reason why
>> > my
>> > program panics now and my question is why is a struct field without a
>> > name
>> > invalid ? Anonymous fields are supposed to have no field names, right?
>> >
>> >  https://github.com/golang/go/issues/20600
>>
>> Yes, unfortunately we had to change the way that it worked.  To make
>> an anonymous field, set the name to the type name and set Anonymous to
>> true.
>>
>> Ian
>
> --
> 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.

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


[go-nuts] net/http GET request with params

2017-12-11 Thread Darko Luketic
Hello,

I'm really puzzled.
I tried Set and Add. Request.Url.Query() is empty
Do I have to build the uri first before and then passing it to 
http.NewRequest?

func HybridFlow() {
   response_type := "code id_token"
   scope := "openid profile email"
   nonce := uniuri.New()
   state := uniuri.New()
   requri := "https://some_uri";
   client := http.DefaultClient
   client.Timeout = time.Second * 10
   req, e := http.NewRequest(http.MethodGet, requri, nil)
   if e != nil {
  log.Fatal(e)
   }
   req.URL.Query().Set("scope", scope)
   req.URL.Query().Set("response_type", response_type)
   req.URL.Query().Set("nonce", nonce)
   req.URL.Query().Set("state", state)
   req.URL.Query().Set("client_id", ClientID)
   req.URL.Query().Set("client_secret", ClientSecret)
   req.URL.Query().Set("redirect_uri", RedirectURI)

   fmt.Println("query", req.URL.Query())

   rsp, e := client.Do(req)
   if e != nil {
  log.Fatal(e)
   }
   fmt.Println(rsp)
   body, e := ioutil.ReadAll(rsp.Body)
   if e != nil {
  log.Fatal(e)
   }
   fmt.Printf("%s", body)
}

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


[go-nuts] For loop in go templating

2017-12-11 Thread Josh Cox
Why is there not a 'for' action in go templating 
?

I seem to get punted for asking such blasphemy!

my stackoverflow question 


and my [github 
issue](https://github.com/golang/go/issues/23088#issuecomment-350871434)

But it's a serious question, the range action does not seem to fit what I 
want here ( which is a simple loop over a count ).

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


Re: [go-nuts] For loop in go templating

2017-12-11 Thread Ian Lance Taylor
On Mon, Dec 11, 2017 at 6:41 PM, Josh Cox  wrote:
>
> Why is there not a 'for' action in go templating?
>
> I seem to get punted for asking such blasphemy!
>
> my stackoverflow question
>
> and my [github
> issue](https://github.com/golang/go/issues/23088#issuecomment-350871434)
>
> But it's a serious question, the range action does not seem to fit what I
> want here ( which is a simple loop over a count ).

In general the template support is not intended to provide support for
general purpose programming, because the templates are necessarily
embedded in a language that already does provide general purpose
programming, namely Go itself.  If you need something complicated,
write Go code.

Ian

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


[go-nuts] Re: For loop in go templating

2017-12-11 Thread Miki Tebeka
You can probably organize the data a bit before sending it to the template 
and use "range". Something similar to https://play.golang.org/p/us5ABFoaeB

On Tuesday, December 12, 2017 at 6:43:06 AM UTC+2, Josh Cox wrote:
>
> Why is there not a 'for' action in go templating 
> ?
>
> I seem to get punted for asking such blasphemy!
>
> my stackoverflow question 
> 
>
> and my [github issue](
> https://github.com/golang/go/issues/23088#issuecomment-350871434)
>
> But it's a serious question, the range action does not seem to fit what I 
> want here ( which is a simple loop over a count ).
>

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