[go-nuts] overflow bugs in bytes.Repeat, strings.Repeat

2016-06-30 Thread Patrick Smith
Seeing the discussion of strings.Repeat and invalid inputs in another thread, I noticed a couple of bugs. One I have reported - https://github.com/golang/go/issues/16237 The other I'm not sure if it's worth a report. Here's the source for bytes.repeat: 391 func Repeat(b []byte, count int) []b

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

2016-06-30 Thread Andrew Mezoni
>> it can be done with using unsafe This is the only available method (and very suitable). The same method used throughout in the Go language the runtime. It's very easy to do that. Problem only to find appropriate syntax for the current Go grammar for to be look as idiomatic Go. I still not fou

[go-nuts] GIMP plugins written in pure Go

2016-06-30 Thread simran
Hi All, Does anyone know of any GIMP plugins written in pure Go. I'm wanting to write some image modification stuff and want to plug it into GIMP, and being able to look at samples would really help. thanks, simran. ps: The inspiration is coming from a blog by Alex Parella wrote "Dynamic Image

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

2016-06-30 Thread Jaden Teng
Thanks for mention this. On Friday, July 1, 2016 at 10:44:42 AM UTC+8, Matt Harden wrote: > > I imagine this will get you at least part of the way: > https://godoc.org/golang.org/x/crypto/pbkdf2 > > On Thu, Jun 30, 2016 at 7:50 AM > wrote: > >> Please see OpenSSL >> >> https://www.openssl.org/doc

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

2016-06-30 Thread Matt Harden
I imagine this will get you at least part of the way: https://godoc.org/golang.org/x/crypto/pbkdf2 On Thu, Jun 30, 2016 at 7:50 AM wrote: > 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. >

[go-nuts] GUI for Go

2016-06-30 Thread Sangeeth Kumar
I use liteide in Windows and I'm really satisfied with its features. There are multiple minor options that make you work seamlessly, almost avoiding the use of command line itself. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

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

2016-06-30 Thread Dan Kortschak
On Thu, 2016-06-30 at 19:10 -0700, Chad wrote: > I have explained why it was not sufficient upstream. > I don't expect people to create two version of their types, one being > for mere inclusion into maps. > Not really; you've said it's not necessary and you've pointed to map[interface{}]interface

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

2016-06-30 Thread Joshua Boelter
If you want to use the s3manager Downloader to gain parallel/chunked downloads, you can use a temp buffer like so. The seek error your getting is because it's using a io.WriterAt interface for io and pipes can't seek when you chain commands together (at least that I know of). https://gist.gith

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

2016-06-30 Thread Chad
> > You don't have to, you can use a pointer indirection instead. > > I have explained why it was not sufficient upstream. I don't expect people to create two version of their types, one being for mere inclusion into maps. -- You received this message because you are subscribed to the Google

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

2016-06-30 Thread Dan Kortschak
On Thu, 2016-06-30 at 18:48 -0700, Chad wrote: > Again, if you really understand the datastructure and what it > represents, the behaviour is really not surprising. There is no value > "abstraction". CS and software engineering is abstractions all the way down. > > And currently, a comparison pan

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

2016-06-30 Thread Chad
Again, if you really understand the datastructure and what it represents, the behaviour is really not surprising. There is no value "abstraction". And currently, a comparison panics. Any interface comparison may panic if the underlying type is a slice. I don't see a good reason for that. That's

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

2016-06-30 Thread Dan Kortschak
On Thu, 2016-06-30 at 18:15 -0700, Chad wrote: > No, it's actually fine. You are comparing values. The issue is that, yes while everything is a value, the value abstraction is tenuous in this context. The result of this tenuous abstraction is that there would be surprising behaviours (already outl

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.

[go-nuts] Donovan/Kernighan Go book $16.83 on Amazon right now.

2016-06-30 Thread Shawn Milochik
http://amzn.com/0134190440 I was just looking up the link to recommend it to someone and saw that it's pretty much half price. I don't know how long it'll last, but I thought I'd share. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscr

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:

[go-nuts] Re: GUI for Go

2016-06-30 Thread Juan F . Giménez Silva
I've done some stuff with gotk https://github.com/gotk3/gotk3 It's a gtk3 binding set and is pretty easy to use. I'm not sure if it supports Windows. El miércoles, 29 de junio de 2016, 22:51:44 (UTC-3), Wen-Pin Hsieh escribió: > > Hi all, > > I am new to go language. > Now I am trying to develop

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 lazy init (not strictly

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 fro

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: 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] Calling a Windows DLL with golang.org/x/sys/windows instead of syscall

2016-06-30 Thread Ian Lance Taylor
On Thu, Jun 30, 2016 at 11:36 AM, Shy Robbiani wrote: > 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 sy

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 UTC

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}. > > > They are not since creat

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 un

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 specify the semantics for

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" >> l

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

2016-06-30 Thread Chad
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. Basically if you have a map[interface{}]interface{} because you have a mixed bag of value that you fill at runtime, you cannot actually use any type you want as th

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

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 c

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

2016-06-30 Thread Michael Whatcott
Ah yes, operations that can and will fail are different than those that fail because of a logic error. Thanks! On Thursday, June 30, 2016 at 10:27:18 AM UTC-6, Ian Lance Taylor wrote: > > On Thu, Jun 30, 2016 at 9:17 AM, Michael Whatcott > wrote: > > The blog post on error handling in go estab

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 equal, especially since m

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

[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(&aws.Config{Region: aws.String("us-west-2")})) result, err := s3Svc.GetObject(&s3.GetObjectInput{ Bucket: aws.String(bucket), Key:aws.String(key),

[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, &s3.GetObjectInput{ ... }) > >

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

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 clea

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

Re: [go-nuts] Return different structs

2016-06-30 Thread Jose Bogarin Solano
Simon, Thanks for the information. Ordering the book at this moment. On 30 June 2016 at 02:35, Simon Ritchie wrote: > By the way, this is covered by in Donovan & Kernighan's new book The Go > Programming Language. On pages 197 and 198 of the first edition, they > describe an interface Expr,

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

2016-06-30 Thread Andy Balholm
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-negative (and not too large) before calling Repeat, rather than checking an error afterward. Using a uint would actually be worse, since uint(int(-1))

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 it, I wouldn't > expe

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 occur (as distinct >> from

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

2016-06-30 Thread Chad
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 it, I wouldn't expect the slices to be equal anymore. The argument that

[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 wrote: >> >> Btw I would

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

2016-06-30 Thread Konstantin Khomoutov
On Thu, 30 Jun 2016 11:22:00 -0400 Shawn Milochik wrote: > I don't know of a Go solution, but if you are on Linux you could try > pdftotext and parse the text. With the obvious caveat of "it depends > on how the PDF was encoded." I'm using this approach in one of my applications. The only probl

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

2016-06-30 Thread charraster
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" > language into some idiomatic Go and compile it with the standard compiler? > (I gues

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

2016-06-30 Thread Ian Lance Taylor
On Thu, Jun 30, 2016 at 1:35 AM, Sankar wrote: > > Are there any stable/production-quality golang libraries that people are > aware of which could read and extract tabular data out of PDF documents ? I don't know if it does what you want, but have you looked at https://godoc.org/rsc.io/pdf ? Ian

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

2016-06-30 Thread Shawn Milochik
I don't know of a Go solution, but if you are on Linux you could try pdftotext and parse the text. With the obvious caveat of "it depends on how the PDF was encoded." Worst-case you may be able to use tesseract OCR to generate text and then do the same thing. https://packages.debian.org/sid/poppl

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

2016-06-30 Thread 'Paul Borman' via golang-nuts
It would be very surprising to people to use a slice as a key to map, say []int{1,2} and then find that using another []int{1,2} does not find that entry. While I think it would be nice to have == on slices, I must agree with Ian and authors that it is better left unsaid. -Paul On Thu, Jun 3

[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

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

2016-06-30 Thread awickert
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 it using sync.Once(). > > Is it required for some reason that the

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

2016-06-30 Thread awickert
Am Donnerstag, 30. Juni 2016 08:57:11 UTC+2 schrieb Lazytiger: > > 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 == "fals

[go-nuts] Сrypto library Themis wrapper for Go language

2016-06-30 Thread borysova . mary
*Themis provides:* - Strong authentication built around Secure Comparator , which allows to authenticate users, requests and compare secrets between parties without established channel trust. - Strong data-at

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 写道: > >> Rijndael -- You recei

Re: [go-nuts] Prevent RTS from creating an OS thread

2016-06-30 Thread Martynas Pumputis
I see :-/ One very fragile workaround I've had in mind is to replace any occurrence of syscall.Syscall by syscall.Rawsyscall within call graph of doSomeStuff(). However, the Go scheduler is not truly cooperative, so unexpected preemption can happen during the execution (e.g. due to a stack growth)

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 it

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

2016-06-30 Thread Nick Craig-Wood
I forgot to add - don't call `wg.Add(1)` inside the go routine - it is racy! If you are trying to start a pool of go routines, you can find that none of them get scheduled before you run the wg.Wait(). -- Nick Craig-Wood -- http://www.craig-wood.com/nick -- You received this message because yo

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 con

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 what you're looking for

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

2016-06-30 Thread Peter Waller
Hi Sankar, It may not be exactly what you're looking for but I can't resist the opportunity to plug our product! PDFTables.com has a remote API, you can see an example of how to use it here: https://github.com/pdftables/api/blob/master/go/cmd/pdftables-api/main.go You can get an API key and find

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

Re: [go-nuts] Return different structs

2016-06-30 Thread Simon Ritchie
By the way, this is covered by in Donovan & Kernighan's new book The Go Programming Language. On pages 197 and 198 of the first edition, they describe an interface Expr, representing an expression, then five concrete types that satisfy that interface and contain different sorts of expressions a

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