Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Chad
No, it's actually fine. You are comparing values. A slice being a struct under the hood, for slices you would compare the structs (slice headers) For an interface, you compare two pointers (in the current implementation) etc. "==" is just value comparison everywhere. Everything is a value.

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Dan Kortschak
This position precludes the following use of the equality operator for scalar values: a := 1 b := 1 a == b would be false under the approach below since a and b are not the same set of bits. I think most people would find this a little surprising. On Thu, 2016-06-30 at 09:24 -0700, Chad wrote:

Re: [go-nuts] Re: Singleton pattern for a client handle

2016-06-30 Thread Nathan Fisher
I often put all of my wire-up in main which ensures that it's only one instance. Then I create a struct that all of the dependencies hang off of like loggers and clients. On Thu, 30 Jun 2016 at 23:30, Val wrote: > Indeed. > I find it weird that the authors care more about

Re: [go-nuts] Re: Singleton pattern for a client handle

2016-06-30 Thread Val
Indeed. I find it weird that the authors care more about lazy init (not strictly required for singletons) than about ensuring properly that multiple instanciation cannot happen. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

Re: [go-nuts] Re: Singleton pattern for a client handle

2016-06-30 Thread Ian Davis
On Thu, Jun 30, 2016, at 01:10 PM, awickert wrote: > > > Am Donnerstag, 30. Juni 2016 08:29:32 UTC+2 schrieb krma...@gmail.com: >> I want a single instance of a client handle to be initialized. >> >> Is it ok to declare the instance as >> >> var client MetricsClient >> >> and then initialize

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Chad
I'd rather people were given a correct simple explanation rather than foregoing any explanation because it may appear complex at first sight. Especially since it alters how maps can be used, later on. (the hashing algorithm relies on comparability). On Thursday, June 30, 2016 at 10:32:58 PM

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Jakob Borg
2016-06-30 22:23 GMT+02:00 Chad : >> Your proposition merely moves the semantical constraint to another >> place: as Ian pointed out, if we define equality for slices to be >> something resembling pointer equality suddenly []byte{1, 2} is not equal >> to []byte{1, 2}. > > >

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Chad
> Your proposition merely moves the semantical constraint to another > place: as Ian pointed out, if we define equality for slices to be > something resembling pointer equality suddenly []byte{1, 2} is not equal > to []byte{1, 2}. > They are not since creating a slice allocate a different

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Konstantin Khomoutov
On Thu, 30 Jun 2016 11:57:38 -0700 (PDT) Chad wrote: > In fact I'd rather deal with the general issue by relaxing some > rules, if it's something that is deemed worthy of being dealt with. I think this part of the discussion can be safely closed: since no one is able to

Re: [go-nuts] Re: A proposal for generic in go

2016-06-30 Thread Øyvind Teig
torsdag 30. juni 2016 18.04.13 UTC+2 skrev charr...@gmail.com følgende: > > > > On Wednesday, June 29, 2016 at 3:42:51 PM UTC+2, Øyvind Teig wrote: >> >> The suggestions of generics discussed here and in the referenced >> documentation, will it be possible to compile the "Go-with-generics" >>

[go-nuts] Calling a Windows DLL with golang.org/x/sys/windows instead of syscall

2016-06-30 Thread Shy Robbiani
The Wiki contains an article about "Calling a Windows DLL" ( https://github.com/golang/go/wiki/WindowsDLLs) using syscall. I used this many times since I started working with Go. Now, in the syscall package documentation I read that syscall has been locked down and instead of syscall the

Re: [go-nuts] Error vs. Panic: Should functions like strings.Repeat return an error value?

2016-06-30 Thread Michael Whatcott
Good point integer overflow. Thanks! On Thursday, June 30, 2016 at 10:30:46 AM UTC-6, Andy Balholm wrote: > > When a function is used incorrectly, a panic is appropriate. If the count > comes from an untrusted source, the caller should check that it is > non-negati!e (and not too large) before

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Konstantin Khomoutov
On Thu, 30 Jun 2016 09:55:30 -0700 (PDT) Chad wrote: > I understand the worry but the more I think about it, the less I > think it would end up being a real issue. > > Taking the example of maps... two different maps that have not the > same location in memory are never

[go-nuts] Re: Singleton pattern for a client handle

2016-06-30 Thread Shy Robbiani
If you really need this, Svett Ralchev provides a nice example using sync.Once() in his blog: http://blog.ralch.com/tutorial/design-patterns/golang-singleton/ On Thursday, June 30, 2016 at 8:29:32 AM UTC+2, krma...@gmail.com wrote: > I want a single instance of a client handle to be

[go-nuts] Re: SDK aws S3 Download to stdout

2016-06-30 Thread Walter Garcia
Excellent , this work fine I attach the final sample code s3Svc := s3.New(session.New({Region: aws.String("us-west-2")})) result, err := s3Svc.GetObject({ Bucket: aws.String(bucket), Key:aws.String(key), }) if

[go-nuts] Re: SDK aws S3 Download to stdout

2016-06-30 Thread Walter Garcia
I had already tried this option but does not work this is the error Failed to download file write /dev/stdout: illegal seek Thanks in advance El jueves, 30 de junio de 2016, 0:55:49 (UTC-3), Dave Cheney escribió: > > numBytes, err := downloader.Download(os.Stdout, { ... }) > > Should do it. >

[go-nuts] Re: GUI for Go

2016-06-30 Thread Shy Robbiani
I lost a little bit the focus on this topic but you might take a look at the various projects on Github dealing with GUIs. The following links provide an overview of what's available today. http://libs.club/golang/media/gui https://golanglibs.com/category/gui Qt bindings are just one way to

Re: [go-nuts] Handling dynamic and unknown number of wait groups?

2016-06-30 Thread Michael Jones
Inspectre, Here is a slight modification that may suit your needs: https://play.golang.org/p/dppJOkPcvG Change summary: 1. Added a terse option (‘-t’) so I could see the urls and errors only. 2. Changed the URL queue to a channel so that… 3. …the main loop (lines 139–148) would be

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Chad
I understand the worry but the more I think about it, the less I think it would end up being a real issue. Taking the example of maps... two different maps that have not the same location in memory are never equal, especially since modifying one does not modify the other. It's easily

Re: [go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Ian Lance Taylor
On Thu, Jun 30, 2016 at 9:24 AM, Chad wrote: > It's a view in another array. > Why should they be equal? Unless the second slice is constructed by > subslicing the other as such `[:]`, the slices are different. > > If I were to access one of the slice backing array and mutate

Re: [go-nuts] Error vs. Panic: Should functions like strings.Repeat return an error value?

2016-06-30 Thread Ian Lance Taylor
On Thu, Jun 30, 2016 at 9:17 AM, Michael Whatcott wrote: > The blog post on error handling in go establishes the following guideline: > >> In Go, error handling is important. The language's design and conventions >> encourage you to explicitly check for errors where they

[go-nuts] Error vs. Panic: Should functions like strings.Repeat return an error value?

2016-06-30 Thread Michael Whatcott
The blog post on error handling in go establishes the following guideline: > In Go, error handling is important. The language's design and conventions encourage you to explicitly check for errors where they occur (as distinct from the convention

Re: [go-nuts] Urlwatch

2016-06-30 Thread 'Will Norris' via golang-nuts
I've also had a lot of success using https://github.com/gregjones/httpcache for a few projects On Tue, Jun 28, 2016 at 9:18 AM, Tong Sun wrote: > Just want to get into the loop for future updates... > > > On Saturday, June 25, 2016 at 9:08:23 AM UTC-4, Mohammad Nasirifar

[go-nuts] How PKCS#5 implement in golang

2016-06-30 Thread jaden
Please see OpenSSL https://www.openssl.org/docs/manmaster/crypto/PKCS5_PBKDF2_HMAC.html How the method implement in golang? It's too hard to me. Would you mind give me some suggestion or docs? Thank you very much. -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] How to decrypt data with AES in golang

2016-06-30 Thread Hoping White
Hi, Jason Thanks for the reply. I find this project useful and it works for me like charm. https://github.com/celso-wo/rijndael256/blob/master/rijndael256.go > 在 2016年6月30日,下午3:34,Jason Woods 写道: >

Re: [go-nuts] Handling dynamic and unknown number of wait groups?

2016-06-30 Thread Chris Randles
When dealing with an unknown amount of input, I find https://godoc.org/go4.org/syncutil#Gate a useful alternative to sync.WaitGroup. -- 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

Re: [go-nuts] Handling dynamic and unknown number of wait groups?

2016-06-30 Thread Nick Craig-Wood
Here is some code I wrote which demonstrates a solution. This is a recursive concurrent directory lister which I think is an identical problem to yours - you start with one directory - you find new directories in the course of listing them which you also want to list, but you want to limit the

Re: [go-nuts] Extracting table data out of PDFs

2016-06-30 Thread Sankar P
Yes, I did come across your service when I was searching. I have some PII information and so did not try the service. Having an on-premise solution is encouraging. I will play with it. Thanks. 2016-06-30 14:35 GMT+05:30 Peter Waller : > Hi Sankar, > > It may not be exactly

[go-nuts] Extracting table data out of PDFs

2016-06-30 Thread Sankar
Hi Are there any stable/production-quality golang libraries that people are aware of which could read and extract tabular data out of PDF documents ? Thanks Sankar -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

[go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Chad
On Thursday, June 30, 2016 at 8:32:58 AM UTC+2, Viktor Kojouharov wrote: > > This would probably introduce unnecessary confusion. People are used to > the equality operator comparing values in go, as opposed to references. > It's much better if the slices finally support the equality operator,

Re: [go-nuts] Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Chad
> > The problem is that different programs need different things for slice > equality. Some want pointer equality as you suggest. Some want > element comparisons, as is done for array equality. Without an > obvious semantics for the operation, the language omits it entirely. > That's

[go-nuts] How to decrypt data with AES in golang

2016-06-30 Thread Hoping White
Hi, all I have a C# code to decrypt data as following public static string test(string input, string key) { if (((input == null) || string.IsNullOrEmpty(input.Trim())) || ((input == "false") || (input == "null"))) { return string.Empty;

[go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-30 Thread Viktor Kojouharov
This would probably introduce unnecessary confusion. People are used to the equality operator comparing values in go, as opposed to references. It's much better if the slices finally support the equality operator, even though the comparison speed will depend on the number of items in the

[go-nuts] Singleton pattern for a client handle

2016-06-30 Thread krmayankk
I want a single instance of a client handle to be initialized. Is it ok to declare the instance as var client MetricsClient and then initialize it using sync.Once(). Is it required for some reason that the client be a pointer or are there are other issues with it. My requirement is to be