Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-05 Thread Tamás Gulácsi
AFAIK it's a design decision that a plugin cannot be loaded twice. Protect it with a sync.Once, if you can't avoid calling the loader twice. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

[go-nuts] Rune-by-rune through a stream

2016-11-05 Thread so . query
Just a thought experiment, but what's the idiomatic way to read rune-by-rune from a stream that represents a string of infinite length? The stream itself can be from std.In or continually generated by a function. Would I use bufio.Scanner or bufio.Reader? I suppose its also possible to use a

[go-nuts] Re: Concurrently read map entries into a channel

2016-11-05 Thread 'Keith Randall' via golang-nuts
On Saturday, November 5, 2016 at 7:48:27 AM UTC-7, leob...@gmail.com wrote: > > Hey, > > I have a scenario where I need to iterate over (as many as possible) map > entries and send them into a channel. > The operation on the other end of the channel can take a long time, so > sends on the

[go-nuts] Re: stop go run from printing "exit status 1"?

2016-11-05 Thread Nate Finch
Cool, thanks, done: https://github.com/golang/go/issues/17813 On Saturday, November 5, 2016 at 8:05:00 PM UTC-4, adon...@google.com wrote: > > > It does seem a little bit arbitrary and contrary to UNIX tool design > principles. It's unlikely that this is a compatibility concern for anyone. >

[go-nuts] Re: With GO - Can I say Procedural is better than OO?

2016-11-05 Thread Henry
Go also support first-class function which is an idea brought from functional programming. Anyhow, in my opinion, you shouldn't be too dogmatic about a particular paradigm. There are cases that can be solved elegantly using a particular paradigm and there are cases that will lead to further

[go-nuts] Re: stop go run from printing "exit status 1"?

2016-11-05 Thread adonovan via golang-nuts
On Friday, 4 November 2016 22:49:17 UTC-4, Nate Finch wrote: > > If the script you run with go run returns a non-zero exit status, go run > prints "exit status N" and itself then returns with exit code 1. > > Now, this seems like a double mistake - first off, the only time go run > should print

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-05 Thread Mateusz Dymiński
I started to play with this new plugin feature and I got some problems when I tried to load two different plugins one by one. If I have first plugin as it was describe in the original post and new one: *Interface:* package processor type Processor interface { Process(text string) } *And

Re: [go-nuts] Re: XML Beautifier that doesn't rewrite the document

2016-11-05 Thread Sam Whited
On Sat, Nov 5, 2016 at 2:51 PM, Tong Sun wrote: > The dark voodoo regexp as described here works for many cases. > http://www.perlmonks.org/?node_id=261292 > > But I did found its own limits when trying more samples... Regular expression are, well, regular. This means that

[go-nuts] XML Beautifier that doesn't rewrite the document

2016-11-05 Thread Tong Sun
On Sat, Nov 5, 2016 at 12:26 PM, Sam Whited wrote: > On Fri, Nov 4, 2016 at 4:32 PM, Tong Sun wrote: > > How to beautify a given XML string in GO?... > > ...If all you need is the bulit in indentation you can use > an encoder and its indent method: > >

[go-nuts] Re: building rss aggregator (thousands of goroutines sleeps at the same time)

2016-11-05 Thread Viktor Kojouharov
It's quite efficient to have a lot of goroutines. That's how I update the feeds in my aggregator. Though your network interface might not like it if you try to initiate thousands of connections at the same time. On Friday, November 4, 2016 at 11:14:24 PM UTC+2, Marwan abdel moneim wrote: > > i

Re: [go-nuts] Beautify XML

2016-11-05 Thread Tong Sun
Oh, thank you Sam for both of your points. Each is very valuable to me! Oh, and the third one too. :-) Thanks again! On Sat, Nov 5, 2016 at 12:16 PM, Sam Whited wrote: > I should also state that in this example you could of course just use > MarshalIndent, the point was to

Re: [go-nuts] Beautify XML

2016-11-05 Thread Sam Whited
On Fri, Nov 4, 2016 at 4:32 PM, Tong Sun wrote: > How to beautify a given XML string in GO? > > The xml.MarshalIndent() only apply to a GO structure, not XML strings. Sorry, third time's the charm. I think I didn't understand what you were asking. If all you need is the

Re: [go-nuts] Beautify XML

2016-11-05 Thread Sam Whited
I should also state that in this example you could of course just use MarshalIndent, the point was to show that you could do it manually if you need more customized formatting. On Sat, Nov 5, 2016 at 11:13 AM, Sam Whited wrote: > On Sat, Nov 5, 2016 at 10:57 AM, Tong Sun

Re: [go-nuts] Beautify XML

2016-11-05 Thread Sam Whited
On Sat, Nov 5, 2016 at 10:57 AM, Tong Sun wrote: > So any plan to add beautify a given XML string feature soon? Thx. No, sorry, I was just pointing out that by manipulating a token stream you could probably do it yourself fairly easily. Eg. something like this simple

Re: [go-nuts] Beautify XML

2016-11-05 Thread Tong Sun
On Sat, Nov 5, 2016 at 11:39 AM, Sam Whited wrote: > I've been playing around with an XML token stream processing API: > > https://godoc.org/mellium.im/xmlstream > > It's still experimental, and likely to change, but it would probably > be pretty easy to write a transformer

Re: [go-nuts] Beautify XML

2016-11-05 Thread Sam Whited
On Fri, Nov 4, 2016 at 4:32 PM, Tong Sun wrote: > How to beautify a given XML string in GO? > > The xml.MarshalIndent() only apply to a GO structure, not XML strings. Aside: Note that the language is called "Go", not "GO". I've been playing around with an XML token stream

[go-nuts] Concurrently read map entries into a channel

2016-11-05 Thread leobalduf
Hey, I have a scenario where I need to iterate over (as many as possible) map entries and send them into a channel. The operation on the other end of the channel can take a long time, so sends on the channel may block for a long time. The map is protected by an RWMutex. The map is also rather

[go-nuts] SetDeadline for io.Writer - is this right?

2016-11-05 Thread audrius . butkevicius
Hi, So I have the following: https://play.golang.org/p/dcuhh40DFZ Yet I believe it exposes the following issues: 1. If sendWork is at line 54, it's possible that doWrites will hit line 79, falsely reporting a timeout case due to timing issues. Correct? 2. In case of a real timeout (where the

[go-nuts] Re: With GO - Can I say Procedural is better than OO?

2016-11-05 Thread Simon Ritchie
> Can I say Procedural is better than OO? Better at what? It depends what you are trying to do. The novelist and aeronautical engineer Neville Shute wrote "It has been said an engineer is a man who can do for five shillings what any fool can do for a pound". These days we accept that some