[go-nuts] Re: Sorting user defined collection in multiple ways

2017-07-25 Thread Srinivas Kandula
Thank you very much Valentin !!, This is exactly what i am looking for. Thanks, Srinivas K On Friday, July 21, 2017 at 7:47:13 PM UTC+5:30, Val wrote: > > Hello Srinivas > > The traditional way to achieve this in go (as showcased here > and here >

Re: [go-nuts] Attaching to email and extracting email attachments

2017-07-25 Thread Tamás Gulácsi
Check out github.com/tgulacsi/agostle - it walks the tree of mime parts of mail and converts everything to PDF, but you need the walk part only - which uses mime/multipart reader basically. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Error: opcode not supported on this processor: mips32

2017-07-25 Thread Sander van Harmelen
Thanks for all your help!! Will have a look and play with some options... Sander On 26 Jul 2017, at 03:05, Ian Lance Taylor wrote: > On Sat, Jul 22, 2017 at 12:57 PM, Sander van Harmelen wrote: > > Ok, I managed to get it compiled by first cross compiling

Re: [go-nuts] Attaching to email and extracting email attachments

2017-07-25 Thread jesse junsay
Yes, I've actually tried doing that... but resulting file is gibberish... I might have not done the decoding correctly... Anyway... Thank you... On Wed, Jul 26, 2017 at 1:03 PM, andrey mirtchovski wrote: > I have not done this. It seems relatively easy given the boundary

Re: [go-nuts] Attaching to email and extracting email attachments

2017-07-25 Thread andrey mirtchovski
I have not done this. It seems relatively easy given the boundary delimiter and some of the mime header information to pick out the file contents by searching forward through the []byte to a delimiter and writing the contents from there to the next delimiter to a file, but I have not done this.

Re: [go-nuts] Understanding least significant byte operation

2017-07-25 Thread Pablo Rozas Larraondo
Thanks Matt. That's a very good explanation about the internal bit representation of integers and answers perfectly my question. I really appreciate your help in understanding these operations. Cheers, Pablo On Wed, Jul 26, 2017 at 2:07 PM, Pablo Rozas Larraondo < p.rozas.larrao...@gmail.com>

Re: [go-nuts] Understanding least significant byte operation

2017-07-25 Thread Pablo Rozas Larraondo
Thanks Bakul, I also understand now what Matt Harden was referring to with his comment. At a bit level both operations cause the same effect on the underlying bits of the variable but it's meaning changes depending on the type. All clear! Cheers, Pablo On Wed, Jul 26, 2017 at 1:51 PM, Bakul Shah

Re: [go-nuts] Understanding least significant byte operation

2017-07-25 Thread Matt Harden
No, it's not interpreted differently. In 2's complement arithmetic, addition is the same operation on the underlying bits, whether the number is signed or unsigned. The same goes for negation and subtraction. There is a difference if you consider overflow, but Go doesn't have overflow of the

Re: [go-nuts] Understanding least significant byte operation

2017-07-25 Thread Bakul Shah
[Sorry, didn't see your original response] In the Go *language* (not just the compiler), when x is an unsigned int, -x is treated as a "shorthand" for ^x+1. Another interpretation is that for finite ints all arithmetic operations are modulo the word size. Thus -1 modulo 2^64 is 0x. You

Re: [go-nuts] Understanding least significant byte operation

2017-07-25 Thread Pablo Rozas Larraondo
Ok, I might be understanding this differently then: The -1 * x operation cannot be defined for unsigned integers as -1 overflows. Therefore, -x in the case of unsigned types is interpreted differently by the compiler, resulting in a ^x + 1 operation. Is that a correct assumption? By the way,

Re: [go-nuts] Attaching to email and extracting email attachments

2017-07-25 Thread jesse junsay
Hi Andrey, I was wondering if you have a sample on how to extract the attachment from email and save it to disk/file. I tried reverse engineer the sample code of attaching attachments into an email but cant figure out what to do with the []byte. Have you tried doing this before? Just the

Re: [go-nuts] Re: Merging several XML into 1

2017-07-25 Thread Matt Harden
The decoder will actually accumulate the pages for you, so you only need one Foo: https://play.golang.org/p/VDZvoJaSZW On Tue, Jul 25, 2017 at 6:56 AM wrote: > I change some structs so now it works as expected. > Here's the playground:

Re: [go-nuts] Parsing XML with namespaces in golang

2017-07-25 Thread Matt Harden
When you leave the namespace out, it will match that tag in *any* namespace (or none). On Mon, Jul 24, 2017 at 11:56 PM Konstantin Khomoutov wrote: > On Mon, Jul 24, 2017 at 07:44:33PM -0700, emartinez1...@gmail.com wrote: > > [...] > >>> So I'm trying to unmarshal an XML with

Re: [go-nuts] Correct way to track each individual goroutine

2017-07-25 Thread Glen Huang
Do you mind explain a bit more as to what is linear view and what is a serial view? Also I think syncWaitGroup should be fine if I stick a context to exec.Command and guarantee it's execution time. On Tuesday, July 25, 2017 at 6:57:19 PM UTC+8, Jesper Louis Andersen wrote: > > On Tue, Jul 25,

[go-nuts] Re: Correct way to track each individual goroutine

2017-07-25 Thread Glen Huang
oh, never thought about that. Initially there will be only server but it's only matter of time I need to scale to multiple servers. I'll probably give redis a shot. Thanks for the suggestion! On Wednesday, July 26, 2017 at 8:33:59 AM UTC+8, Florin Pățan wrote: > > Will the user always end up

Re: [go-nuts] Understanding least significant byte operation

2017-07-25 Thread Matt Harden
Both statements are true for both signed and unsigned integers. On Mon, Jul 24, 2017, 04:11 Pablo Rozas Larraondo < p.rozas.larrao...@gmail.com> wrote: > Thanks Bakul, I think I have a better understanding of what's going on > after reading your response. > > Is it correct to say that the Go

Re: [go-nuts] Is there some way to set value for unexported nil ptr field of a struct using reflect?

2017-07-25 Thread Ian Lance Taylor
On Sun, Jul 23, 2017 at 12:46 AM, feilengcui008 wrote: > Hi, all: > I'm writing a little fuzz tool for struct using reflect package, and > came across the following case, but didn't find any way to solve it > > > type TestStruct struct { > a *int //

Re: [go-nuts] Error: opcode not supported on this processor: mips32

2017-07-25 Thread Ian Lance Taylor
On Sat, Jul 22, 2017 at 12:57 PM, Sander van Harmelen wrote: > > Ok, I managed to get it compiled by first cross compiling libusb and then > pointing to it using the linker flags you suggested. So thank you very much, > I can now compile a binary that works on the target device

[go-nuts] Correct way to track each individual goroutine

2017-07-25 Thread Florin Pățan
Will the user always end up on the same server for subsequent requests after the upload one? If the answer is no or not sure then keep the state in Memcached (or similar place) and that's the best way to go forward with it. -- You received this message because you are subscribed to the Google

Re: [go-nuts] How to break a long code into lines in Golang?

2017-07-25 Thread Ian Lance Taylor
On Tue, Jul 25, 2017 at 4:38 PM, yihao yang wrote: > > I have some problems on break long code into lines when developing in > golang. > Could you please help me on how to break a long code as following? > time.Sleep(time.Duration(*Int64Flag_xxIntervalMS) * >

[go-nuts] How to break a long code into lines in Golang?

2017-07-25 Thread yihao yang
Hi, I have some problems on break long code into lines when developing in golang. Could you please help me on how to break a long code as following? time.Sleep(time.Duration(*Int64Flag_xxIntervalMS) * time. Millisecond - time.Now().Sub(timeStart)) Thanks, Yihao -- You received

Re: [go-nuts] pet peeve: it's Go not golang

2017-07-25 Thread Andy Balholm
Even “go game of life” works. Some search engines may treat “of” as a stopword, but Google gives it some weight. Andy > On Jul 25, 2017, at 4:18 PM, Skip Tavakkolian > wrote: > > I was specifically referring to things posted to this list to avoid the old >

Re: [go-nuts] Reasoning behind behavior of range, when index is maintained

2017-07-25 Thread 'Chris Manghane' via golang-nuts
Hmm, well I can't give better reasoning off the top of my head, but I still have to wonder why you expect the behavior of those constructs to be the same, particularly. Imagine, you would like to capture both the iteration variable and the value itself, for example: var i, v = 0, "" for i, v =

Re: [go-nuts] Reasoning behind behavior of range, when index is maintained

2017-07-25 Thread Steven Hartland
Its likely this is because the idx in a range is just that, its the index of the processing element and not a loop iteration variable. As range never processes an element past the end of the slice, there's no way for it to get set to N, hence the difference in semantics from a normal for i :=

Re: [go-nuts] Re: pet peeve: it's Go not golang

2017-07-25 Thread Skip Tavakkolian
I was specifically referring to things posted to this list to avoid the old chestnut about search. For what it's worth, I don't buy that argument either. Searching for "game of life in go language" works just as well. Correctness matters even when nobody is looking. On Tue, Jul 25, 2017, 2:47 PM

Re: [go-nuts] Reasoning behind behavior of range, when index is maintained

2017-07-25 Thread 'Axel Wagner' via golang-nuts
On Wed, Jul 26, 2017 at 12:52 AM, Chris Manghane wrote: > This is mentioned directly in the language specification under For > statements with range clause : > > For each entry it assigns iteration values to corresponding iteration >>

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-25 Thread ojucie
I propose a new rule for our Code of Conduct: Before posting to the "No Allman-Style, No go!" thread, you shall read and understand all previous posts in the aforementioned thread. Justo to be clear: Go indentation style is a time saver. It was carefuly crafted to piss some people off. As you

Re: [go-nuts] Reasoning behind behavior of range, when index is maintained

2017-07-25 Thread 'Chris Manghane' via golang-nuts
This is mentioned directly in the language specification under For statements with range clause : For each entry it assigns iteration values to corresponding iteration > variables if present and then executes the block. and > For an array, pointer to

[go-nuts] Reasoning behind behavior of range, when index is maintained

2017-07-25 Thread 'Axel Wagner' via golang-nuts
Hey, someone shared [this question]( https://www.reddit.com/r/golang/comments/6paqc0/bug_that_caught_me_with_range/) on reddit. I must say, that I'm surprised by the behavior myself. I would have expected for i = range v to be semantically equivalent to for i = 0; i < len(v); i++ and don't really

Re: [go-nuts] Re: pet peeve: it's Go not golang

2017-07-25 Thread Shawn Milochik
On Jul 25, 2017 5:48 PM, wrote: Yes, the language name is Go, but sometimes real life matters. Imagine I want to search for a Go implementation of Conway's Game of Life, but I don't quite remember the game name, so I search for: go game life Nothing. Otherwise, if I search

Re: [go-nuts] Re: pet peeve: it's Go not golang

2017-07-25 Thread 'Thomas Bushnell, BSG' via golang-nuts
Google Search is weird. I searched for "game of life in go" and all ten links were great hits for just that. When I search for "go game life", the implementation of Conway's game is the fifth link; still not so bad. Thomas On Tue, Jul 25, 2017 at 2:47 PM wrote: > Yes, the

[go-nuts] Re: pet peeve: it's Go not golang

2017-07-25 Thread ojucie
Yes, the language name is Go, but sometimes real life matters. Imagine I want to search for a Go implementation of Conway's Game of Life, but I don't quite remember the game name, so I search for: go game life Nothing. Otherwise, if I search for golang game life I get plenty of entries

[go-nuts] Re: delve

2017-07-25 Thread Derek Parker
Hey, I'd be happy to answer any questions you have. On Monday, July 24, 2017 at 5:40:10 PM UTC-7, Robert Solomon wrote: > > Hi. I need help with using delve. Where should I direct my questions? > > I don't know where else to ask, so I'm asking here first. > > --rob solomon > > -- You

[go-nuts] Re: Go eval the source

2017-07-25 Thread Nathan Kerr
I wrote an expanded explanation for the second option: Exploring alternatives with go run . On Saturday, July 22, 2017 at 4:13:27 PM UTC+2, Tong Sun wrote: > > Fabulous! Thanks Nathan! > > On Saturday, July 22, 2017 at 1:41:12 AM

Re: [go-nuts] pet peeve: it's Go not golang

2017-07-25 Thread 'Thomas Bushnell, BSG' via golang-nuts
And when there is confusion, "Go language" is much nicer to read than "golang". On Tue, Jul 25, 2017 at 11:16 AM Skip Tavakkolian < skip.tavakkol...@gmail.com> wrote: > Although "go" is a verb, an adjective and a noun (including the game), > there shouldn't be any confusion in what Go is, when

Re: [go-nuts] pet peeve: it's Go not golang

2017-07-25 Thread Aram Hăvărneanu
And certainly neither Google Go nor Google golang. -- Aram Hăvărneanu -- 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.

[go-nuts] Re: golang on ec2; terraform, salt, etc.

2017-07-25 Thread Diego Medina
Hi, For what you described, I wouldn't even use Docker (not trying to get into flame wars, just my opinion that not using it will keep your setup even simpler) Some time ago I wrote this https://github.com/fmpwizard/mrwilson/tree/master/ansible it's a complete ansible set of playbooks,

[go-nuts] pet peeve: it's Go not golang

2017-07-25 Thread Skip Tavakkolian
Although "go" is a verb, an adjective and a noun (including the game), there shouldn't be any confusion in what Go is, when posting to a list dedicated to the language. Thanks, -Skip -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] golang on ec2; terraform, salt, etc.

2017-07-25 Thread Sankar
Hi I have a golang REST api server. I cross-compile the monolithic golang binary with GOOS=linux GOARCH=amd64 from my macbook (developer machine) and then scp the binary to a ec2 vm. I have written a systemd service file to manually bring down the service before the scp and bring up after the

Re: [go-nuts] Detecting promoted methods

2017-07-25 Thread nz
On Tuesday, 25 July 2017 09:09:28 UTC-7, Ian Lance Taylor wrote: > > On Tue, Jul 25, 2017 at 9:04 AM, nz > wrote: > > > > Using reflection I would like to be able to determine if a method has > been > > promoted (my use case is detecting if a method is overridden). But

[go-nuts] Go 1.9 Release Candidate 1 is released

2017-07-25 Thread Chris Broadfoot
Hello gophers, We have just released go1.9rc1, a release candidate of Go 1.9. It is cut from release-branch.go1.9 at the revision tagged go1.9rc1. Thank you to everyone who has helped to test Go 1.9 so far. We still need more people to test, especially on production workloads. Your help is

Re: [go-nuts] Detecting promoted methods

2017-07-25 Thread Ian Lance Taylor
On Tue, Jul 25, 2017 at 9:04 AM, nz wrote: > > Using reflection I would like to be able to determine if a method has been > promoted (my use case is detecting if a method is overridden). But there > seems to be no way to detect a promoted method. When I use reflect.Method on >

[go-nuts] Detecting promoted methods

2017-07-25 Thread nz
Using reflection I would like to be able to determine if a method has been promoted (my use case is detecting if a method is overridden). But there seems to be no way to detect a promoted method. When I use reflect.Method on the structs I get two separate method definitions, which makes sense

Re: [go-nuts] Why does this program carry test flags once compiled?

2017-07-25 Thread Howard Guo
Many thanks Chris, that's a wonderful idea and I've successfully got rid of the test mode flags! On Tuesday, 25 July 2017 05:47:30 UTC+2, Chris Broadfoot wrote: > > One way around the flag problem is to accept an interface, instead of > using testing.T. > > Watch Mitchell Hashimoto's talk from

Re: [go-nuts] Math on Huge (2GB) numbers in GoLang

2017-07-25 Thread Michael Jones
The nat->string code allows any base -- or at least it did -- but it was not exposed in the Int APIs. Maybe you'll want to access the sources. On Sun, Jul 23, 2017 at 8:34 PM, me wrote: > > > On Saturday, July 22, 2017 at 9:37:16 AM UTC-6, Rémy Oudompheng wrote: >> >> >> The

[go-nuts] Re: Merging several XML into 1

2017-07-25 Thread alexandre . lemiere
I change some structs so now it works as expected. Here's the playground: https://play.golang.org/p/DXlajwirtt On Tuesday, July 25, 2017 at 2:42:41 PM UTC+2, Alex L wrote: > > Hi, > I'm new to Go, and this is my first post here... > > I need to merge some xml files into 1. > I would prefer

Re: [go-nuts] GoDoc: ignore GOPATH, local serving of help files

2017-07-25 Thread me
> On Monday, July 24, 2017 at 11:06:42 AM UTC-6, Jan Mercl wrote: > >> >> > $ GOPATH= godoc -http :6060 & >> >> >> > For anyone on Windows, use: SET GOPATH= & godoc -http=:6060 (sets an empty gopath, then runs godoc) Then navigate to: http://127.0.0.1:6060/pkg/ -- You received this message

[go-nuts] Re: How to determine when to actually use goroutines?

2017-07-25 Thread me
On Monday, July 24, 2017 at 6:44:10 PM UTC-6, nat...@honeycomb.io wrote: > > > only use goroutines when you know for a fact that you have an issue which > needs solving via concurrency, e.g., IO-bound workloads. While it's nice to > have goroutines and channels within easy reach, they do

Re: [go-nuts] GoDoc: ignore GOPATH, local serving of help files

2017-07-25 Thread me
On Monday, July 24, 2017 at 11:06:42 AM UTC-6, Jan Mercl wrote: > > > $ GOPATH= godoc -http :6060 & > > > Good work around, simply set a dummy blank gopath using the command line environment. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] How come Math Big module has no Pow functions?

2017-07-25 Thread me
On Monday, July 24, 2017 at 11:09:09 AM UTC-6, Jan Mercl wrote: > > On Mon, Jul 24, 2017 at 5:33 PM me wrote: > > > The math unit has Pow() functions.. > > > > How come the Big (math) package has nothing similar? > > It has: https://golang.org/pkg/math/big/#Int.Exp > > Indeed,

[go-nuts] Merging several XML into 1

2017-07-25 Thread Ale
Hi, I'm new to Go, and this is my first post here... I need to merge some xml files into 1. I would prefer using standard library for this task. var XML1 = []byte(` some stuff abc def `) var XML2 = []byte(`

Re: [go-nuts] Re: How to determine when to actually use goroutines?

2017-07-25 Thread Jesper Louis Andersen
In the Erlang world, when people ask this question, we often say: "identify the truly concurrent activities in the system--make those into processes". To wit, a common mistake is to apply too much concurrency in a system where none is needed. If you run a new goroutine, then there has to be a

Re: [go-nuts] Correct way to track each individual goroutine

2017-07-25 Thread Jesper Louis Andersen
On Tue, Jul 25, 2017 at 6:56 AM Glen Huang wrote: > > My current design is that uploading is finished as soon as the image is > uploaded to the server, after which I spawn a goroutine to exec a command > to do the compression. When the user requests the image , I'll wait for

Re: [go-nuts] Correct way to track each individual goroutine

2017-07-25 Thread Gulácsi Tamás
golang.org/x/sync/singleflight is the descendant of go4.org/syncutil/singleflight which is factored out from camlsitore.org :) Konstantin Khomoutov ezt írta (időpont: 2017. júl. 25., K, 9:04): > On Mon, Jul 24, 2017 at 11:47:44PM -0700, Tamás Gulácsi wrote: > > > See

[go-nuts] Re: Correct way to track each individual goroutine

2017-07-25 Thread Glen Huang
Thanks for bringing singleflight to my attention. However, if I'm not wrong, it doesn't seem to fully solve the problem. If after uploading, I call singleflight.Do, and pass the file name and the compression function, when users requests a file, should I call singleflight.Do and pass the

Re: [go-nuts] Correct way to track each individual goroutine

2017-07-25 Thread Konstantin Khomoutov
On Mon, Jul 24, 2017 at 11:47:44PM -0700, Tamás Gulácsi wrote: > See http://godoc.org/go4.org/syncutil/singleflight for another solution. > If you key by file name/id, and the function compresses when needed > and then returns the (de)compressed file, it'll solve your problem. How is that

Re: [go-nuts] Parsing XML with namespaces in golang

2017-07-25 Thread Konstantin Khomoutov
On Mon, Jul 24, 2017 at 07:44:33PM -0700, emartinez1...@gmail.com wrote: [...] >>> So I'm trying to unmarshal an XML with namespaces in go but i just can't >>> find the right parser to do so. [...] >> type Root struct { >> XMLName struct{} `xml:"urn:MNResultsResults MNResultsResults"`

[go-nuts] Correct way to track each individual goroutine

2017-07-25 Thread Tamás Gulácsi
See http://godoc.org/go4.org/syncutil/singleflight for another solution. If you key by file name/id, and the function compresses when needed and then returns the (de)compressed file, it'll solve your problem. -- You received this message because you are subscribed to the Google Groups