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

2016-08-04 Thread Markus Zimmermann
You are right Sebastien, I fixed that. Thanks! On Thursday, August 4, 2016 at 6:58:06 PM UTC+2, Sebastien Binet wrote: > > > > On Thu, Aug 4, 2016 at 1:07 PM, Markus Zimmermann > wrote: > >> I feared that there would be no pure Go solution. Anyway, I used fdopen >> variant the code is here >> h

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

2016-08-04 Thread Debraj Manna
I know this. I am asking about the functionality of the mgo driver while calling SetSafe(nil) & SetSafe(&Safe{})? How mgo will behave in both the cases while doing a write to Mongo? On Fri, Aug 5, 2016 at 11:09 AM, Kiki Sugiaman wrote: > &Safe{} gives you a pointer to a new instance of Safe with

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

2016-08-04 Thread Kiki Sugiaman
&Safe{} 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 a

[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, vis

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

2016-08-04 Thread Debraj Manna
Can someone help me in clearing my doubts? On Aug 4, 2016 4:36 PM, "DM" wrote: > Can someone explain me the difference between the default value of > SetSafe() which is &Safe{}and SetSafe(nil)? > > As per the mgo godoc :- > > If the safe paramet

[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 > https://github.co

Re: [go-nuts] [ANN] CribbNotes CUI

2016-08-04 Thread Asit Dhal
Hi, Does it work in windows ? go get github.com/jroimartin/gocui go get github.com/jameycribbs/cribbnotes_cui go build cribbnotes_cui.go Error : GetFileAttributesEx cribbnotes_cui.go: The system cannot find the file specified. On 8/5/2016 02:27, Jamey Cribbs wrote: Hi, everyone. I would

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 wrote:

[go-nuts] Re: a net.Listener aggregator

2016-08-04 Thread Daniel Garcia
Whoops, forgot the link. https://godoc.org/github.com/daniel-garcia/multilistener On Thursday, August 4, 2016 at 7:57:57 PM UTC-5, Daniel Garcia wrote: > > 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 a

[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 aggregate

[go-nuts] [ANN] CribbNotes CUI

2016-08-04 Thread Jamey Cribbs
Hi, everyone. I would like to announce the first release of CribbNotes CUI (https://github.com/jameycribbs/cribbnotes_cui). CribbNotes CUI is a simple, console-user-interface note taking application written in Go and using the awesome gocui library. Cribb

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

[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 rec

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 t

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 tests pass. But that >>> would change the type

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 Number

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

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 possible. > > > Even though t

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 https://golang.or

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: >> >> >> >> Fwiw, io.EOf can be converted to a co

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 appr

[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 https://groups.google.com/d/optout.

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 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: > >> > >> Fwiw, io.EOf can be converted to a constant, all the tests pass. But > that > >>

[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 libraries

Re: [go-nuts] Reject Unknown clients

2016-08-04 Thread Sam Whited
On Thu, Aug 4, 2016 at 9:17 AM, Naveen Shivegowda wrote: > Is it possible to make http servers listen only on a few source ip's and > request from any other source should be rejected? Out of curiosity, is there a reason you don't want to use a firewall for this? iptables and pf are pretty great.

Re: [go-nuts] Re: Reject Unknown clients

2016-08-04 Thread Manlio Perillo
Il giorno giovedì 4 agosto 2016 17:38:10 UTC+2, Naveen Shivegowda ha scritto: > > Hi > Thanks for the reply. > Which method can be used from http pkg to filter ip's, I didn't find any > in golang.org > > See https://golang.org/pkg/net/http/#Request. You can use RemoteAddr field to find the client

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:13 AM, T L wrote: > > 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

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

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

2016-08-04 Thread Seb Binet
On Thu, Aug 4, 2016 at 1:07 PM, Markus Zimmermann wrote: > I feared that there would be no pure Go solution. Anyway, I used fdopen > variant the code is here https://github.com/zimmski/ > osutil/blob/master/capture.go#L51 if anyone every stumbles over this > thread. > seems to me like you're lea

[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 nee

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

2016-08-04 Thread Ian Lance Taylor
On Thu, Aug 4, 2016 at 8:52 AM, Michael Bubb wrote: > > 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 > > > > > > > >

[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 209.8

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] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-04 Thread T L
On Thursday, August 4, 2016 at 2:19:06 PM UTC+8, Jesse McNelis wrote: > > 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 ne

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

2016-08-04 Thread Dave Cheney
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. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving email

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 covered by the Go 1 cont

[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 more

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 > (https://github.com/g

Re: [go-nuts] Re: Reject Unknown clients

2016-08-04 Thread Naveen Shivegowda
Hi Thanks for the reply. Which method can be used from http pkg to filter ip's, I didn't find any in golang.org On Aug 4, 2016 8:56 PM, "Hotei" wrote: > Certainly possible. You can put the whitelisted IPS in a map and use that > to filter the incoming requests. > > On Thursday, August 4, 2016 a

[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 shou

[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 woul

[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 htt

[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] Re: How to capture stderr/stdout of cgo calls?

2016-08-04 Thread Markus Zimmermann
I feared that there would be no pure Go solution. Anyway, I used fdopen variant the code is here https://github.com/zimmski/osutil/blob/master/capture.go#L51 if anyone every stumbles over this thread. Thanks for the help. On Monday, July 25, 2016 at 1:00:46 PM UTC+2, Uli Kunitz wrote: > > Your

[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 &Safe{}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, witho

[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 a

[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" group

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

2016-08-04 Thread ondrej . kokes
Excellent, now it's all consistent. Thank you, sir. https://play.golang.org/p/cKANdyqXen Still a bit confused as to why the code elimination in the previous examples yielded code with such differing performance, but at I'm glad that locality was not the culprit. Thanks everyone for your input.

[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 * t

[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 golang-nuts+unsubscr...@googlegro

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

2016-08-04 Thread pi
For several millions of goroutines - yes I think it matters. 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, sen

[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 m

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

2016-08-04 Thread pi
Hi. I'd like to write function with spin-loop like this: func readWait(timeout time.Duration) bool { deadline := Nanotime() + timeout.Nanoseconds() for { if readAvail() { return true } if Nanotime() >= deadline { return false } runtime.Goshed() } } But runtime.nanotime() is not exported. How can