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 email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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


[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.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 program doesn't work because changing os.Stdout and os.Stdin has no 
>> effect on stdio stdin and stdout. Stdio stdout will still reference fd 1 
>> and stderr fd 2.
>>  
>> I recommend following three solutions:
>>
>>
>>1. The simplest approach could be not to use cgo at all and run the C 
>>code in a separate process. Capturing the output of a separate process is 
>>simple and can be done using the os/exec package.
>>2. Reset stdin and stdout using fdopen in the C code. This could be 
>>done permanently.
>>3. Swap file descriptors using dup2.
>>
>>  
>>  
>>  
>>
>

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

> 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 interface value
>
> I am currently working on the Number and plurals package. I planned to not
> expose "amount" in the currency API until it is clear how all of this is
> going to look like, as to avoid having to change the currency API later.
>
> Ideally we would also have a 128-bit precision decimal float type
> available in core or the text package before finalizing such API.
>
> If this is really blocking, I could consider adding like a Value (or
> Amount?) method to return the underlying raw interface of the amount. This
> would not necessarily be incompatible with adding, for instance, a Decimal
> and/or Number method later, although no guarantees it won't change.
>
> Marcel
>
>
>
> On Thu, Aug 4, 2016 at 11: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/golang/text/blob/master/currency/format.go#L26). Any
>> update on this?
>>
>> I would love to use this package to store currency value and pass around
>> my application. But there is currently no way to extract the stored amount.
>>
>> --
>> 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] 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 aggregates connections from the underlying listeners.

Regards,
Daniel

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

Issue: https://github.com/golang/go/issues/16400

CL: https://go-review.googlesource.com/#/c/25510/

Thanks,
Sina

-- 
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: 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 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] 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 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 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 of an exported symbol, so it's not possible.
>>
>>
>> Even though the type is not exported?
>> I can't see where the https://golang.org/doc/go1compat document forbids this
>> case.
>
> Changing the type of io.EOF so that it is no longer type `error` would
> break this package.
>

Ah, right; thanks.

errors.New returns a value of type error.


> [...]

Manlio

-- 
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] 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 interface value

I am currently working on the Number and plurals package. I planned to not
expose "amount" in the currency API until it is clear how all of this is
going to look like, as to avoid having to change the currency API later.

Ideally we would also have a 128-bit precision decimal float type available
in core or the text package before finalizing such API.

If this is really blocking, I could consider adding like a Value (or
Amount?) method to return the underlying raw interface of the amount. This
would not necessarily be incompatible with adding, for instance, a Decimal
and/or Number method later, although no guarantees it won't change.

Marcel



On Thu, Aug 4, 2016 at 11: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/golang/text/blob/master/currency/format.go#L26). Any
> update on this?
>
> I would love to use this package to store currency value and pass around
> my application. But there is currently no way to extract the stored amount.
>
> --
> 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.


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 - if 
this was for a business I'd have to agree with you on using a proper 
firewall.

On Thursday, August 4, 2016 at 1:16:42 PM UTC-4, Sam Whited wrote:
>
> 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. Or, if you're already 
> terminating HTTP elsewhere with a loadbalancer like HAProxy you can do 
> it at that level. Plenty of options that don't require more 
> application code. 
>
> —Sam 
>
>
> -- 
> Sam Whited 
> pub 4096R/54083AE104EA7AD3 
>

-- 
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 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 the type is not exported?
> I can't see where the https://golang.org/doc/go1compat document forbids this
> case.

Changing the type of io.EOF so that it is no longer type `error` would
break this package.

package p

import "io"

var P *error = 

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] 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.org/doc/go1compat document forbids 
this case.


Manlio

-- 
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 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 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
>> > into constant, its type is still error.
>>
>> Try it.
>>
>> Ian
>
>
> could you elaborate it? do you mean to modify the core lib src and rebuild
> it?

Yes, for example.  It's quite easy to do.

You will find that you can not write a const of type error, because
error is an interface type.

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] 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 appreciated

On Thu, Aug 4, 2016 at 12:18 PM, Ian Lance Taylor  wrote:

> 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
> >
> >
> >
> >
> >
> >
> >
> > ▶ curl -v https://play.golang.org/p/hmQb12rl5v
> > *   Trying 209.85.232.141...
> > * Connected to play.golang.org (209.85.232.141) port 443 (#0)
> > * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
> > * Server certificate: misc-sni.google.com
> > * Server certificate: Google Internet Authority G2
> > * Server certificate: GeoTrust Global CA
> >> GET /p/hmQb12rl5v HTTP/1.1
> >> Host: play.golang.org
> >> User-Agent: curl/7.43.0
> >> Accept: */*
> >>
> > < HTTP/1.1 403 Forbidden
> > < Strict-Transport-Security: max-age=31536000; preload
> > < Content-Type: text/plain; charset=utf-8
> > < X-Content-Type-Options: nosniff
> > < X-Cloud-Trace-Context: f822e86c231dd9506c5c49645e765a40
> > < Date: Thu, 04 Aug 2016 15:48:58 GMT
> > < Server: Google Frontend
> > < Content-Length: 10
> > < Alternate-Protocol: 443:quic
> > < Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32,31,30"
> > <
> > Forbidden
> > * Connection #0 to host play.golang.org left intact
> >
> >
> >
> > I am at home behind a static ipv4 connection. I also tested with a vpn
> > connection (tunnelr).
> >
> > What should I futher troubleshoot on this?
>
> Please open an issue at https://golang.org/issue with information
> about the IP address you are connecting from.
>
> Note that play.golang.org is not accessible from certain geographical
> regions; if you can, see https://golang.org/issue/12908 .
>
> Ian
>



-- 
Michael Bubb   +1.646.783.8769 | KD2DTY
Resume - http://mbubb.devio.us/res/resume.html
gpgkey: http://mbubb.devio.us/gpg/pub_key.asc

*"Our apologies, good friends, for the fracture of good order..." *

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


[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?  I could set the LD_LIBRARY_PATH but I would rather look to 
another method.

Thanks,

-- 
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 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 
into constant, its type is still error.

-- 
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: 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 needing the binary as an argument since 1.7 etc.

Or maybe just an example in the package 
file https://golang.org/pkg/runtime/trace/

On Thursday, 20 August 2015 11:40:49 UTC+1, Egon wrote:
>
> On Wednesday, 19 August 2015 23:32:16 UTC+3, Shan Valleru wrote:
>>
>> In Go 1.5, it seems like you can generate a execution flow diagram (like 
>> this - https://talks.golang.org/2015/dynamic-tools/trace.png) for a go 
>> program using trace command .
>> Anybody know the detailed steps for generating such a flow diagram from a 
>> go program?
>>
>
> Here's the code I used to create a 10s trace from a server. You should be 
> able to modify it to your own needs.
>
> import "runtime/trace"
>
> func trace10(w http.ResponseWriter, r *http.Request) {
> f, err := os.Create(time.Now().Format("2006-01-02T150405.pprof"))
> if err != nil {
> panic(err)
> }
> defer f.Close()
>
> if err := trace.Start(f); err != nil {
> panic(err)
> }
> defer trace.Stop()
>
> // All the important stuff is happening in other goroutines so we just 
> wait here
> time.Sleep(10 * time.Second)
> }
>
> Once you have integrated that into your own code whatever way you need:
>
> // on Linux you can create/analyze it as:
> go build .
> ./program
> go tool trace program 2015-08-20T133508.pprof
>
> // on Windows
> go build .
> program.exe
> go tool trace program.exe 2015-08-20T133508.pprof
>

-- 
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] 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.85.232.141...
* Connected to play.golang.org (209.85.232.141) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: misc-sni.google.com
* Server certificate: Google Internet Authority G2
* Server certificate: GeoTrust Global CA
> GET /p/hmQb12rl5v HTTP/1.1
> Host: play.golang.org
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< Strict-Transport-Security: max-age=31536000; preload
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< X-Cloud-Trace-Context: f822e86c231dd9506c5c49645e765a40
< Date: Thu, 04 Aug 2016 15:48:58 GMT
< Server: Google Frontend
< Content-Length: 10
< Alternate-Protocol: 443:quic
< Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32,31,30"
<
Forbidden
* Connection #0 to host play.golang.org left intact



I am at home behind a static ipv4 connection. I also tested with a vpn 
connection (tunnelr).

What should I futher troubleshoot on this?

thanks

-- 
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: 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 something like this?
>
> func (b *RingBuf) ReadWait(min uint32, timeout time.Duration) bool {
> if min ==  {min = 1}if b.ReadAvail() >= min {
> return true}if timeout.Nanoseconds() ==  {return false
> }const pollPeriod = 100 * time.Nanosecondniter :=
> int64(timeout.Nanoseconds() / pollPeriod.Nanoseconds())
>
> for i := int64(); i < niter; i++ {if b.ReadAvail() >= min {
> return true}time.Sleep(pollPeriod) } return false }
>
>> 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...@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] 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 contract"
> I don't very understand. Could you explain more?

https://golang.org/doc/go1compat

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

>
> On Thursday, 4 August 2016 14:20:18 UTC+10, T L wrote:
>>
>> http://dave.cheney.net/2016/04/07/constant-errors
>>
>

-- 
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] 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/golang/text/blob/master/currency/format.go#L26). Any
> update on this?
>
> I would love to use this package to store currency value and pass around my
> application. But there is currently no way to extract the stored amount.
>
> --
> 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: 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 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 email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 
bug in my code on an image path that did not exist on the other comp thus 
explaining why it did not work.   

Le mercredi 3 août 2016 15:19:52 UTC+2, Alain Milicevic a écrit :
>
> Hi,
>
> i have a program that imports a package from github.com/abc... 
> when i build the .exe how can i have the package/dependency included in 
> the .exe ? 
>
> thanks,
> Al
>
>
>

-- 
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] 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 would love to use this package to store currency value and pass around my 
application. But there is currently no way to extract the stored amount.

-- 
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: 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 http 
package.

On Thursday, August 4, 2016 at 12:27:18 AM UTC+2, David Marceau wrote:
>
> I tried just what you mentioned.  Unfortunately even my interim solution 
> when it is outside of the net.http package and within mine, there are many 
> services that are not exported meaning I can't use them at all and the 
> variables themselves are inaccessible.
> I tried copying pasting some functions and tweaking them and I ended up 
> going down a rabbit hole never to get out of.  The only way to achieve what 
> I want would be to tweak the original golang sources for 
> net.http.ListenAndServeTLS and stuff surrounding it.
>
>
> On Wednesday, August 3, 2016 at 9:19:40 AM UTC-4, Nathan Kerr wrote:
>>
>> Your research revealed the essential lines from ListenAndServeTLS that 
>> basically say: 
>>
>> 1. create a tls listener 
>> 2. have the server serve using that listener 
>>
>> The LimitListener example follows this same pattern, just with 
>> net.Listener instead of a tls.Listener. A careful reading reveals that 
>> ListenAndServeTLS does not do anything to http.Server that you cannot do 
>> from outside the http package. This means that you can implement it in your 
>> own code; changing it to fit your needs. Your code will probably flow 
>> something like: 
>>
>> 1. get a listener 
>> 2. limit that listener 
>> 3. create a tls.Config 
>> 4. tlslistener on LimitedListener with config 
>> 5. Server.Serve(tlsListener) 
>>
>> I am not sure if it would be better to limit before or after the tls 
>> listener. 
>>
>> I call this trick expanding convenience functions and explain it in 
>> regards to another problem at 
>> http://pocketgophers.com/expanding-convenience-functions/ (
>> http://pocketgophers.com/expanding-convenience-functions/). 
>>
>> To answer your other questions: 
>>
>> I think that tlsListener is not part of the Server structure (so that you 
>> could easily fetch it and limit it) is for two reasons. First, it keeps the 
>> server and the listener separate. There is no fundamental reason that a 
>> single server could not serve on multiple listeners. 
>>
>> Second, Serve is basically an infinite loop waiting on Listener.Accept. 
>> What would it mean to change the server's listener while it is blocked 
>> accepting a new connection? The old listener would be blocking. If a 
>> connection was never made to it, the new listener would never accept any 
>> connections. 
>>
>> The API does give the control you need, just not in the way you looked 
>> for it. 
>>
>> For that last question, controlling connections is usually done as a way 
>> to control the use of some other resource such as cpu, memory, database 
>> access, etc. Managing resources must be done at both the OS and server 
>> level. What needs to be done depends on what the server needs to do, what 
>> hardware it is running on, service level agreements, etc. Sometimes 
>> limiting, sometimes expanding limits, sometime increasing performance. 
>>
>> Hope this helps.
>
>

-- 
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] 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 email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 error checking. The unsafe mode is faster since 
operations won't hold on waiting for a confirmation.

If the safe parameter is not nil, any changing query (insert, update, ...) will 
be followed by a getLastError command with the specified parameters, to ensure 
the request was correctly processed.

The default is {}, meaning check for errors and use the default behavior 
for all fields.

Looking at the code 
 it 
seems it will call getLastError with values j:false, w:0, wtimeout:0. This 
means it will not return any error from mongo and the behavior seems to be 
similar while calling SetSafe(nil).

Then what error I am expected to receive while calling mongo with 
SetSafe({})?

I am on Mongo 3.0.9.

-- 
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: 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 at 7:37:35 PM UTC+4:30, atd...@gmail.com wrote:
>
> No it can have its uses.
>
> It really depends on what you are doing. However, I've never done this as 
> a way to declare some kind of namespace.
>
> Typically, I use that in testing when I want a dummy type to implement an 
> interface.
>
> That's just an example.
>
> It can be used also if you export the struct type. That allows to transfer 
> a group of functions (closer to your idea of namespace).
> Instead of exporting each function separately.
>

-- 
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: 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.
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: 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 * time.Nanosecond

niter := int64(timeout.Nanoseconds() / pollPeriod.Nanoseconds())


for i := int64(0); i < niter; i++ {

if b.ReadAvail() >= min {

return true

}

time.Sleep(pollPeriod)

}

return false

}


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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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


[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 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: 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 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] 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 following struct to represent a special []interface{},
> the concrete type of all interface{} values in the []interface{} is the same
> one.
>>
>> type specialInterfaceSlice struct {
>>   typ *_type
>>   values []T
>> }
>

That avoids the copy, but makes it impossible to take the address of
an interface{} in that []interface{}.

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