Re: [go-nuts] SetSafe default value in mgo session

2016-08-04 Thread Kiki Sugiaman
{} gives you a pointer to a new instance of Safe with zero value for all its fields. https://tour.golang.org/basics/12 -- 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

[go-nuts] Re: Namespacing hack using method on empty type

2016-08-04 Thread Christoph Berger
Are there any advantages over using real packages? -- 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,

[go-nuts] Re: How to capture stderr/stdout of cgo calls?

2016-08-04 Thread mattn
I guess calling freopen is better because cgo possibly having reference of stdin/stdout as FILE*. On Thursday, August 4, 2016 at 8:07:40 PM UTC+9, Markus Zimmermann wrote: > > I feared that there would be no pure Go solution. Anyway, I used fdopen > variant the code is here >

Re: [go-nuts] Status of golang.org/x/text/currency (github.com/golang/text)?

2016-08-04 Thread Johan Sim
Hi Marcel, Thanks for sharing the plan. I'll pay close attention to this package. I actually have an existing private package that works but moving to a public working package would lower the maintenance cost and perhaps also guarantee a higher quality. Johan On Fri, 5 Aug 2016 at 03:00

[go-nuts] a net.Listener aggregator

2016-08-04 Thread Daniel Garcia
I looked for an example of someone implementing a fan in pattern for net.Listener but didn't find one. I wrote one for a personal project and I'm posting here in case it's useful to anyone else. It allows you to take a list of net.Listener objects and it returns a single listener that

[go-nuts] net/http/httptrace: new hook for end of request life cycle (please comment and review)

2016-08-04 Thread Sina Siadat
Hi go-nuts, I have been working on a new httptrace hook to find out the end of a request life cycle. This new hook (RequestCompleted) is called with a provided error indicating whether the request was completed successfully. I was wondering if I could get your opinions and comments about it.

[go-nuts] Re: Server TCP

2016-08-04 Thread freddymontero324
The login package is a message that the device sends to the server to request a connection, for example, the device send 0001 to the server, to start the communication and the server answer would be 1002 telling to the device that they are connected, now the data sharing can start -- You

Re: [go-nuts] Reject Unknown clients

2016-08-04 Thread Kiki Sugiaman
This is not necessarily directed at the OP but anyone considering this approach: If you already know about ip spoofing attack, great. Otherwise, do proceed with that in mind. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] Re: Why doesn't std lib use the method in this article to make err variables constant?

2016-08-04 Thread Manlio Perillo
On Thu, Aug 4, 2016 at 8:21 PM, Ian Lance Taylor wrote: > On Thu, Aug 4, 2016 at 11:19 AM, Manlio Perillo > wrote: >> Il giorno giovedì 4 agosto 2016 17:54:33 UTC+2, Dave Cheney ha scritto: >>> >>> Fwiw, io.EOf can be converted to a constant, all the

Re: [go-nuts] Status of golang.org/x/text/currency (github.com/golang/text)?

2016-08-04 Thread mpvl
Hi Johan, I do plan to provide some kind functionality of this nature, I'm just not quite sure yet how. It could either be: - the API as proposed - returning an interface{} value of the underlying amount that the user would need to cast to the appropriate type, - returning some

Re: [go-nuts] Reject Unknown clients

2016-08-04 Thread Hotei
Sam, I'm guessing but a lot of (non-commercial) folks use an inexpensive "wireless router" with NAT as their "firewall". Besides, the application code is trivial. Probably less than a hundred lines. Potentially s a good teaching moment for using go and how it does http. On the other hand -

Re: [go-nuts] Re: Why doesn't std lib use the method in this article to make err variables constant?

2016-08-04 Thread Ian Lance Taylor
On Thu, Aug 4, 2016 at 11:19 AM, Manlio Perillo wrote: > Il giorno giovedì 4 agosto 2016 17:54:33 UTC+2, Dave Cheney ha scritto: >> >> Fwiw, io.EOf can be converted to a constant, all the tests pass. But that >> would change the type of an exported symbol, so it's not

Re: [go-nuts] Re: Why doesn't std lib use the method in this article to make err variables constant?

2016-08-04 Thread Manlio Perillo
Il giorno giovedì 4 agosto 2016 17:54:33 UTC+2, Dave Cheney ha scritto: > > Fwiw, io.EOf can be converted to a constant, all the tests pass. But that > would change the type of an exported symbol, so it's not possible. Even though the type is not exported? I can't see where the

Re: [go-nuts] Re: Why doesn't std lib use the method in this article to make err variables constant?

2016-08-04 Thread Ian Lance Taylor
On Thu, Aug 4, 2016 at 10:47 AM, T L wrote: > > On Friday, August 5, 2016 at 1:14:38 AM UTC+8, Ian Lance Taylor wrote: >> >> On Thu, Aug 4, 2016 at 10:13 AM, T L wrote: >> > >> > On Thursday, August 4, 2016 at 11:54:33 PM UTC+8, Dave Cheney wrote: >> >> >>

Re: [go-nuts] getting 403 forbidden when I try to access go plaground examples

2016-08-04 Thread Michael Bubb
Thanks - your advice about "geo regions" made me look at my current routing table. My provider (Optimum in NJ) is having a Bad Day and apparently is routing all my traffic through Quebec... 13 hops to ping my own router. I will let them resolve this before submitting an issue to github. Much

[go-nuts] Linking c libraries

2016-08-04 Thread Tamás Gulácsi
man ldconfig -- 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

[go-nuts] Linking c libraries

2016-08-04 Thread Rich
I have an issue in that I wrote this application that uses github.com/mattn/go-oci8 and it runs on Linux x64. I get the following error: "error while loading shared libraries: libclntsh.so.11.1" How can I compile it so that when run the executable will look to a specific path for the

Re: [go-nuts] Re: Why doesn't std lib use the method in this article to make err variables constant?

2016-08-04 Thread T L
On Thursday, August 4, 2016 at 11:54:33 PM UTC+8, Dave Cheney wrote: > > Fwiw, io.EOf can be converted to a constant, all the tests pass. But that > would change the type of an exported symbol, so it's not possible. sorry, I still don't get it. The type of io.EOF is error. After changing it

[go-nuts] Re: Generating execution trace diagram for a go program

2016-08-04 Thread ondrej . kokes
This is excellent, really helpful. The -help flag only mentions testing and casual searching only again pops up with info on more testing, I couldn't see anything on actually using it for running a generic binary. Perhaps it would be worth adding this to the documentation? + things like not

[go-nuts] getting 403 forbidden when I try to access go plaground examples

2016-08-04 Thread Michael Bubb
Hello Our chief data scientist at work was showing me an example of a prime sieve in golang. He shared this with me: https://play.golang.org/p/49awp0a7jv I get a 403 forbidden when I try to access that or any other example ▶ curl -v https://play.golang.org/p/hmQb12rl5v * Trying

Re: [go-nuts] Re: How to wait for specified amount of time in a loop without timer overhead

2016-08-04 Thread Ian Davis
Maybe you could investigate something like this: https://www.snellman.net/blog/archive/2016-07-27-ratas-hierarchical-timer-wheel/ Disclaimer: I've not tried that method, but I saw it recently and filed it away as potentially useful -- Ian On Thu, Aug 4, 2016, at 11:14 AM, pi wrote: > You mean

Re: [go-nuts] Re: Why doesn't std lib use the method in this article to make err variables constant?

2016-08-04 Thread Ian Lance Taylor
On Thu, Aug 4, 2016 at 8:43 AM, T L wrote: > > On Thursday, August 4, 2016 at 1:48:32 PM UTC+8, Dave Cheney wrote: >> >> Because we cannot change symbols covered by the Go 1 contract. > > > Aha, you are the author of this article. Great article! > >> "cannot change symbols

[go-nuts] Re: Why doesn't std lib use the method in this article to make err variables constant?

2016-08-04 Thread T L
On Thursday, August 4, 2016 at 1:48:32 PM UTC+8, Dave Cheney wrote: > > Because we cannot change symbols covered by the Go 1 contract. > Aha, you are the author of this article. Great article! > "cannot change symbols covered by the Go 1 contract" I don't very understand. Could you explain

Re: [go-nuts] Status of golang.org/x/text/currency (github.com/golang/text)?

2016-08-04 Thread Ian Lance Taylor
[ +mpvl ] On Thu, Aug 4, 2016 at 2:07 AM, Johan Jian An Sim wrote: > There is no issue section in this repository to start a discussion. > > I would like to ask about the status of currency package. There seems to be > plan for further development according to the comments >

[go-nuts] Re: Reject Unknown clients

2016-08-04 Thread Hotei
Certainly possible. You can put the whitelisted IPS in a map and use that to filter the incoming requests. On Thursday, August 4, 2016 at 10:17:37 AM UTC-4, Naveen Shivegowda wrote: > > Is it possible to make http servers listen only on a few source ip's and > request from any other source

[go-nuts] Re: building an exe that will embed import in the .exe

2016-08-04 Thread Alain Milicevic
Zdravo Zlatko, I thought that too but after building an .exe and copying/moving it to another comp, it behaved as if it worked but did not generate a file, so i thought the imported package was not embedded in the .exe So after your response i looked more carefully in the code and i noticed a

[go-nuts] Status of golang.org/x/text/currency (github.com/golang/text)?

2016-08-04 Thread Johan Jian An Sim
There is no issue section in this repository to start a discussion. I would like to ask about the status of currency package. There seems to be plan for further development according to the comments (https://github.com/golang/text/blob/master/currency/format.go#L26). Any update on this? I

[go-nuts] Re: how to apply netutil.LimitListener() to ListenAndServeTLS()'s listener? how to fetch ListenAndServeTLS()'s listener?

2016-08-04 Thread Nathan Kerr
I managed to expand ListenAndServeTLS and then apply LimitedListener. My code and process are posted at https://pocketgophers.com/limit-https-listener/ tcpKeepAliveListener ended up being the only code that was copied but not specialized. It would have been nice if it were exported from the

[go-nuts] Reject Unknown clients

2016-08-04 Thread Naveen Shivegowda
Is it possible to make http servers listen only on a few source ip's and request from any other source should be rejected? -- 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

[go-nuts] SetSafe default value in mgo session

2016-08-04 Thread DM
Can someone explain me the difference between the default value of SetSafe() which is {}and SetSafe(nil)? As per the mgo godoc :- If the safe parameter is nil, the session is put in unsafe mode, and writes become fire-and-forget, without

[go-nuts] Re: Namespacing hack using method on empty type

2016-08-04 Thread dc0d
Personally I do that (despite that everyone advocates against it). Just remember your struct should be just "struct{}" and nothing else. This helped me to use shorter & cleaner names for my functions - actually it converts a function pile to a batch of functions). On Wednesday, August 3, 2016

[go-nuts] Re: Data locality in large slices

2016-08-04 Thread Dave Cheney
I believe rsc once quipped "If it doesn't have to be correct, I can make [this code] very fast". I don't think you can make performance comparisons between two pieces of code if one is incorrect. -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Re: How to wait for specified amount of time in a loop without timer overhead

2016-08-04 Thread pi
You mean something like this? func (b *RingBuf) ReadWait(min uint32, timeout time.Duration) bool { if min == 0 { min = 1 } if b.ReadAvail() >= min { return true } if timeout.Nanoseconds() == 0 { return false } const pollPeriod = 100 *

[go-nuts] Re: How to wait for specified amount of time in a loop without timer overhead

2016-08-04 Thread Dave Cheney
I think it would be cheaper to call time.Sleep than spinning on runtime.Gosched. -- 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

[go-nuts] How to wait for specified amount of time in a loop without timer overhead

2016-08-04 Thread Dave Cheney
If you're going to sleep, does it matter if time.Sleep has a cost? -- 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

[go-nuts] IDE for GOLANG

2016-08-04 Thread Florin Pățan
You can try any IDE from JetBrains and it should support Go. Among debugging and other things, see what the latest release brought to it: http://go-ide.com/releases/0.11.1725/ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

[go-nuts] Re: files, readers, byte arrays (slices?), byte buffers and http.requests

2016-08-04 Thread Tamás Gulácsi
If md5 is enough at the end, use an io.T eeReader. If not, you need to buffer it, with bytes.Buffer. That can be reused with sync.Pool (don't forget the Reset). For mime, the first 1024 bytes is enough. Read that into a [1024]byte and create a Reader with io.MultiReader. -- You received this

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-04 Thread Jesse McNelis
On Thu, Aug 4, 2016 at 3:33 PM, T L wrote: > > With some special memory optimizations for slice, I think it is possible to > make efficient conversions from []T to []interface. > For example, we don't need to convert every element in []T to interface{}, > we can just use