Re: [go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread 'chris dollin' via golang-nuts
Every call of xrand calls .Int() on a fresh generator initialised the same way as the previous one, so it will give the same result. The calls to .Int() in main are all on the /same/ generator, which is updated by each call, so you get three different values. Chris On 8 May 2017 at 11:26, wr

Re: [go-nuts] Parsing base64 data with headers

2017-04-06 Thread 'chris dollin' via golang-nuts
On 6 April 2017 at 12:00, Ain wrote: > ie there are some headers and then base64 encoded data. I suspect there > might be some functions in the std lib which should be able to parse this > and give me easy access to the headers and data but I just can't find it... > it isn't mime/multipart, righ

Re: [go-nuts] []struct{} vs. []*struct{}

2017-01-11 Thread 'chris dollin' via golang-nuts
On 11 January 2017 at 09:21, Henry wrote: > My understanding is that a slice is an array of pointers. No. A []T (slice of Ts) contains the length and capacity of the slice and a pointer to the backing array of the slice. The backing array is an array of elements of type T (not /pointer/ to T).

Re: [go-nuts] Why doens't function type support comparision but channel type does?

2016-11-23 Thread 'chris dollin' via golang-nuts
If functions are comparable you have to be very careful in defining /when/ they are equal. func f(x int)int {return x+2} func g(x int)int {return x+2} func h(x int)int {return x+1+1} Are f and g equal? f and h? func k() func (int)int { return func(int x)int {x + 1}} Are k() and k() equal? f and

Re: [go-nuts] Is it a compiler bug?

2016-11-12 Thread 'chris dollin' via golang-nuts
On 12 November 2016 at 07:33, imd3c wrote: > package main > > import ( > "fmt" > ) > > func main() { > /* > s := "*/" > */ > > fmt.Println("Hello, playground") > } And asked if this: > > tmp/sandbox035254559/main.go:9: newline in string > tmp/sandbox035254559/main.go:10: syntax error: unexpe

Re: [go-nuts] Defer question

2016-10-11 Thread 'chris dollin' via golang-nuts
Your assignments in the deferred function are to the local variable `err`, not the return value of `Execute` -- you can't change the return value in the deferred function unless it has a name. You want to write func Execute() (err error) { defer func() { ... Now the return value is n

Re: [go-nuts] overriding keywords or rather allowing them to be part of a struct in go?

2016-10-04 Thread 'chris dollin' via golang-nuts
On 4 October 2016 at 07:32, David Luu wrote: > Say I wanted to define a struct like this: > > type runKeywordReturnType struct{ > return interface{} > status string > output string > error string > traceback string > } > > Seems to not work since return and error are go keywords. If I ca

Re: [go-nuts] json package error ?

2016-10-03 Thread 'chris dollin' via golang-nuts
On 3 October 2016 at 10:16, Marcin Jurczuk wrote: > Hi, > > I hit some issue with son.Marshal string parsing and I don't know is it > package error or "this is not a bug - it's a feature". > > Here is code that doesn't work like expected: > https://play.golang.org/p/vAOhLCtoSh > > > Why I'm gettin

Re: [go-nuts] Re: first program, game of life in go

2016-07-28 Thread 'chris dollin' via golang-nuts
On 28 July 2016 at 09:04, Carl Ranson wrote: > I've seen some code that suggests that chan interface{} is a valid. > what can you send on that? Anything. The receiver has to know what to do with it, of course. Chris -- Chris "allusive" Dollin -- You received this message because you are su