[go-nuts] Re: what can I do about this interface conversion error

2018-05-01 Thread alex . rou . sg
If basicNode isn't the only struct that could be passed, I would argue that that's cleaner than checking for every possible type. Also doing it that way means that your interface couldn't care less about the actual structure of the struct and so is much more flexible. And they won't break if and

Re: [go-nuts] Re: Go could really use a while statement

2018-05-01 Thread Michael Jones
The 'do' in this could be a 'for' if for allowed an optional 'while' after the close brace. On Tue, May 1, 2018 at 9:08 PM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > I have a preferred methtod for emulating do-while: > > notdone:=true > for notdone { > > if { > notdone

[go-nuts] Re: Go could really use a while statement

2018-05-01 Thread Louki Sumirniy
I have a preferred methtod for emulating do-while: notdone:=true for notdone { if { notdone = false } } I prefer to use a negative name because I don't see why I should use a unary operator when I can just use the word NOT and not incur any runtime cost. or for ! { } The for

[go-nuts] Re: what can I do about this interface conversion error

2018-05-01 Thread naha
Thanks for your help and patience Alex. I guess I need to do something like https://play.golang.org/p/qURVD3of5oU but I find it kind of unclean to have to add private methods to do this. It wouldn't be appropriate to define a basicNode getter method on the node interface since basicNode is

Re: [go-nuts] Is GC affected by array size, and if so, when and how?

2018-05-01 Thread Ian Lance Taylor
On Tue, May 1, 2018 at 1:17 PM, wrote: > > That is all as I anticipated, but I don't know where this is documented. The fact that the GC does not scan the contents of a [1000]byte is not user visible, so it doesn't really belong in user documentation. I would start with the

Re: [go-nuts] proposal: embed static assets

2018-05-01 Thread Ian Lance Taylor
On Tue, May 1, 2018 at 1:28 PM, John Unland wrote: > > So something like x/tools/cmd/assets or cmd/assets? Yes. I might use a name more like cmd/embed. > I was just now thinking about it more today and I was wondering if something > like this could maybe be implemented

[go-nuts] Re: what can I do about this interface conversion error

2018-05-01 Thread alex . rou . sg
You can't do that with interfaces, embedding struct or not. You can only call methods on interfaces or assert to a type. On Wednesday, 2 May 2018 05:48:26 UTC+8, Mark Nahabedian wrote: > > b2 isn't in my most recent example. Thus gets the error that n2.inputs is > not defined. > > func (n1

[go-nuts] Re: what can I do about this interface conversion error

2018-05-01 Thread naha
b2 isn't in my most recent example. Thus gets the error that n2.inputs is not defined. func (n1 *basicNode) OutputsTo(n2 node) { n2.inputs = append(n2.inputs, n1) n1.outputs = append(n1.outputs, n2) } -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: what can I do about this interface conversion error

2018-05-01 Thread alex . rou . sg
> > That shows that basicNode's inputs and outputs fields are not visible as > fields of ActionNode or TestNode though. Yup, struct embedding is just a shortcut to writing wrapper functions. Even if basicNode's fields gets promoted to ActionNode's fields, doing b2 := n2.(*basicNode) Wouldn't

[go-nuts] Re: what can I do about this interface conversion error

2018-05-01 Thread naha
I was expecting that since basicNode is anonymously embedded into TestNode and ActionNode, that the methods and fields of basicNode would all be present in TestNode and ActionNode. In that case I'd have expected https://play.golang.org/p/gIvykcxFTmQ to have worked. That shows that

Re: [go-nuts] proposal: embed static assets

2018-05-01 Thread John Unland
So something like *x/tools/cmd/assets* or *cmd/assets*? I was just now thinking about it more today and I was wondering if something like this could maybe be implemented into *go build*. Like how you can assign variables at build time: *go build -ldflags="-X main.Foo=Bar"* Into something

Re: [go-nuts] Is GC affected by array size, and if so, when and how?

2018-05-01 Thread time4dan
That is all as I anticipated, but I don't know where this is documented. Any chance you could point me in the right direction? Even in the source code, the closest I could come to an answer was something to do with type "spans", but I'm so unfamiliar with the terminology... -- You received

Re: [go-nuts] Is GC affected by array size, and if so, when and how?

2018-05-01 Thread Ian Lance Taylor
On Tue, May 1, 2018 at 1:00 PM, wrote: > > I looked at the source but can't understand it well enough. > > If I allocate a [1000]byte, or a []byte, I understand the GC will need to > mark the slice/array itself for collection. However, does the GC mark all > the bytes within,

[go-nuts] Is GC affected by array size, and if so, when and how?

2018-05-01 Thread time4dan
I looked at the source but can't understand it well enough. If I allocate a [1000]byte, or a []byte, I understand the GC will need to mark the slice/array itself for collection. However, does the GC mark all the bytes within, and does the marking phase attempt to follow all the items? Will

[go-nuts] Re: what can I do about this interface conversion error

2018-05-01 Thread alex . rou . sg
Struct embedding works like this: type ActionNode struct { basicNode } Turns into: type ActionNode struct { basicNode basicNode } func (a *ActionNode) OutputsTo(n2 node) { a.basicNode.OutputsTo(n2) } So basicNode will behave as a field of ActionNode with wrapper functions. If you

Re: [go-nuts] Go could really use a while statement

2018-05-01 Thread Justin Israel
On Wed, May 2, 2018, 1:56 AM Michael Jones wrote: > Maybe he meant "until" aka "do {...} while cond" -- this is a valuable and > missing mechanism. The argument back in the day was that having just one > looping construct was more friendly to tooling. > Based on this...

[go-nuts] what can I do about this interface conversion error

2018-05-01 Thread naha
I don't know why I'm getting this interface conversion error or what to do about it. I define an interface, node, and a struct, basicNode that implements behavior common to all nodes. I also define ActionNode and TestNode which both anonymously embed basicNode. basicNode implements OutputsTo

[go-nuts] Windows OneDrive issue ..

2018-05-01 Thread xiofen77
I just discovered a problem running/compiling files that are accessed/backed up by windows OneDrive (don't know when this started - worked a couple of months ago..) So I have a simple go file at C:\Users\xiool\OneDrive\go ie test.go At the command line all variants of go run

Re: [go-nuts] Go could really use a while statement

2018-05-01 Thread xiofen77
> > On Tue, May 1, 2018 at 7:36 AM Alisdair > wrote: > >> Isn't `for { ... if cond { break; } }` the same as `do {...} while cond`? >> Whilst having the benefits of not adding new keywords and maintaining the >> logic of the loop entirely within the block of the loop

[go-nuts] Re: Go 1.10.2 and Go 1.9.5 are released

2018-05-01 Thread Nathan Kerr
I updated my release related resources: - Go Release Timeline - When Should You Upgrade Go? Nathan On Tuesday, May 1, 2018 at 10:04:38 AM UTC-7, Andrew Bonventre wrote: > > Hi

SV: [go-nuts] 1: json: cannot unmarshal array into Go value of typemain.Catcher or 2: json: cannot unmarshal object into Go value of typemain.Crypto4

2018-05-01 Thread Michael Banzon
You are declaring your struct as []struct and then using it as ”var collect []Crypto4” effectively doubling the arraynes  See this: https://play.golang.org/p/Q3RzNddeVVT And on a side note: Please check your errors – especially if Things doesn’t work – a few err != nil along with

Re: [go-nuts] Go could really use a while statement

2018-05-01 Thread Alisdair
Isn't `for { ... if cond { break; } }` the same as `do {...} while cond`? Whilst having the benefits of not adding new keywords and maintaining the logic of the loop entirely within the block of the loop making it simpler to understand. On Tue, 1 May 2018 at 14:56, Michael Jones

[go-nuts] Go 1.10.2 and Go 1.9.5 are released

2018-05-01 Thread Andrew Bonventre
Hi gophers, We have just released Go versions 1.10.2 and 1.9.6, minor point releases. These releases include fixes to the compiler, linker, and go command. View the release notes for more information: https://golang.org/doc/devel/release.html#go1.10.minor You can download binary and source

Re: [go-nuts] float accuracy when calculating Fibonacci numbers

2018-05-01 Thread Marvin Renich
* andrey mirtchovski [180430 17:41]: > > math.Pow does not give as precise answers as the C++ std lib. > > math pow doesn't just multiply X by itself Y times, it uses a > different algorithm: > > https://golang.org/src/math/pow.go#L40 Sure, I understand that. However,

Re: [go-nuts] Go could really use a while statement

2018-05-01 Thread Michael Jones
Correct. On Tue, May 1, 2018 at 7:36 AM Alisdair wrote: > Isn't `for { ... if cond { break; } }` the same as `do {...} while cond`? > Whilst having the benefits of not adding new keywords and maintaining the > logic of the loop entirely within the block of the loop

[go-nuts] Re: Looking for go programmers for game company

2018-05-01 Thread matthewjuran
I may be interested. Can you share background about your company here? Thanks, Matt On Saturday, April 28, 2018 at 10:52:01 PM UTC-5, smga...@gmail.com wrote: > > Hey gophers. I have a multi platform game company that is also integrating > blockchain technology as well as crypto currency. I am

[go-nuts] 1: json: cannot unmarshal array into Go value of type main.Catcher or 2: json: cannot unmarshal object into Go value of type main.Crypto4

2018-05-01 Thread m_@li
Hi ! I was searching relevant posts regarding error "json: cannot unmarshal array into Go value of type main.Catcher" or "json: cannot unmarshal object into Go value of type main.Crypto4". These two error messages are linked to the same program (depends on when I change structure). Actually

Re: [go-nuts] Go could really use a while statement

2018-05-01 Thread Michael Jones
Maybe he meant "until" aka "do {...} while cond" -- this is a valuable and missing mechanism. The argument back in the day was that having just one looping construct was more friendly to tooling. On Tue, May 1, 2018 at 5:45 AM Ian Lance Taylor wrote: > On Tue, May 1, 2018 at

Re: [go-nuts] Go could really use a while statement

2018-05-01 Thread Ian Lance Taylor
On Tue, May 1, 2018 at 4:11 AM, Hugh Fisher wrote: > > Another observation from this novice Go programmer: I'm puzzled why > there's no while statement. > > I know it's possible to use a for, but it doesn't feel right to me. I always > think of for loops as for iterating

[go-nuts] Go could really use a while statement

2018-05-01 Thread Hugh Fisher
Another observation from this novice Go programmer: I'm puzzled why there's no while statement. I know it's possible to use a for, but it doesn't feel right to me. I always think of for loops as for iterating over data structures. Originally just arrays, but languages like Python and Objective-C