[go-nuts] Re: I am confused.

2018-05-27 Thread alex . rou . sg
Then you shouldn't even have a google account/gmail and shouldn't be posting on google groups. https://support.google.com/accounts/answer/1350409?hl=en > For all countries not listed below, 13 is the minimum age to manage your > own Google Account. The only legit way for you to have a google

Re: [go-nuts] Re: I am confused.

2018-05-27 Thread alex . rou . sg
That's why I also linked discord (age 13) and irc On Sunday, 27 May 2018 17:07:10 UTC+8, David Skinner wrote: > > https://invite.slack.golangbridge.org/ > You Must be Over the Age of 16 to use chat server. > > You must be over age 13 to use GitHub > > On Sat, May 26, 2018 at 11:07 PM > wrote: > >>

[go-nuts] Re: I am confused.

2018-05-26 Thread alex . rou . sg
Have you not seen my post about joining a chat server? Instead of waiting a day or so for each reply, people could reply instantly and hold your hand through setting things up. On Sunday, 27 May 2018 11:37:48 UTC+8, John wrote: > > Well I guess I would just use the Go playground so it is easier.

[go-nuts] Re: how to reuse getters and setters of two different versions of struct ? [interface{}/generics]

2018-05-25 Thread alex . rou . sg
This is what interfaces are for. You have: type GetKeyer interface { GetKey1() string GetKey2() string } Then to use it: https://play.golang.org/p/rvLsWCIBuxe You still have to implement GetKey1 and GetKey2 on each struct, but you can access them through a common interface without knowin

[go-nuts] Re: Freeing memory of a cgo library

2018-05-25 Thread alex . rou . sg
Nope, not ATM. Go only works with gcc, even the dlls are made with gcc. There is a issue on that and it seems like there is some progress but it isn't clear when it will be usable. https://github.com/golang/go/issues/20982 Also note that even if Go uses msvc, you would still have issues freeing

[go-nuts] Re: Freeing memory of a cgo library

2018-05-25 Thread alex . rou . sg
Memory allocated by one C/C++ runtime must and can only be freed through the same runtime. This is not a Go/cgo problem, this is normal C/C++ behavior. So by mixing gcc and msvc there are at least 2 C/C++ runtimes. Even mixing different compiler versions might cause issues. On Saturday, 26 May

Re: [go-nuts] Why doesn't this select statement timeout?

2018-05-24 Thread alex . rou . sg
No, not the entire case statements, only the statements on the right of the "<-" btw if you run it out of the playground (which makes concurrency more deterministic) You would get timeout sometimes and nil sometimes Also maybe this example would help you understand what's going on. https://play

[go-nuts] Re: I am confused.

2018-05-23 Thread alex . rou . sg
I would suggest you join a chat server so people can guide you through the whole process with a quicker response time than the hours you are waiting for each reply on a forum such as this one. https://discordapp.com/invite/PxwHvBS https://invite.slack.golangbridge.org/ #go-nuts on irc.freenode.n

Re: [go-nuts] Why doesn't this select statement timeout?

2018-05-22 Thread alex . rou . sg
https://golang.org/ref/spec#Select_statements Execution of a "select" statement proceeds in several steps: > >1. For all the cases in the statement, the channel operands of receive >operations and the channel and right-hand-side expressions of send >statements are evaluated exactly o

[go-nuts] Re: What powers search on golang.org?

2018-05-20 Thread alex . rou . sg
Tho there is also the offline one used by godoc https://github.com/golang/tools/blob/4e70a1b26a7875f00ca1916637a876b5ffaeec59/godoc/search.go On Monday, 21 May 2018 05:27:53 UTC+8, alex@gmail.com wrote: > > > https://github.com/golang/blog/blob/a317451f36b22672c8a079489aa5425b9fa3a9da/content

[go-nuts] Re: What powers search on golang.org?

2018-05-20 Thread alex . rou . sg
https://github.com/golang/blog/blob/a317451f36b22672c8a079489aa5425b9fa3a9da/content/context/google/google.go Google search On Monday, 21 May 2018 04:08:18 UTC+8, meir fischer wrote: > > golang.org let’s you search all stdlib go source code. > > For example, see https://golang.org/search?q=hello

[go-nuts] Re: Why does unmarshalling this API response return an unexpected EOF?

2018-05-14 Thread alex . rou . sg
I do not see escaped quotes on your stackoverflow post, can you post the raw json exactly as received? On Tuesday, 15 May 2018 05:16:59 UTC+8, Luke IC wrote: > > Thanks again for the help. Unfortunately it's a third-party API, so I > won't be able to fix it myself. The full error message is as f

[go-nuts] Re: Why does unmarshalling this API response return an unexpected EOF?

2018-05-14 Thread alex . rou . sg
In the long term I would investigate what's wrong with the json and if possible fix it at the source. Also use this as a reference on what gets mapped to what https://developers.google.com/protocol-buffers/docs/proto3#json On Tuesday, 15 May 2018 05:03:46 UTC+8, Luke IC wrote: > > Thanks a lot,

[go-nuts] Re: Why does unmarshalling this API response return an unexpected EOF?

2018-05-14 Thread alex . rou . sg
You need to use the go protobuf json decoder https://github.com/golang/protobuf/tree/master/jsonpb On Monday, 14 May 2018 11:24:06 UTC+8, Luke IC wrote: > > Hi all, > > I'm creating a microservice in Go, using protocol buffers and gRPC. It > interacts with a third-party API (Snooth) and I'm tryi

[go-nuts] Re: Writing a Compiler for Web Assembly

2018-05-11 Thread alex . rou . sg
If you clicked under Issues you'll see the first result is https://github.com/golang/go/issues/18892 On Friday, 11 May 2018 19:59:39 UTC+8, Chris FractalBach wrote: > > So I've been playing around with compilers lately, and thought it might be > fun to write a compiler from Go to web assembly! >

Re: [go-nuts] cross-compile mac to linux

2018-05-07 Thread alex . rou . sg
There's a tool for that, and yeah it uses docker. https://github.com/karalabe/xgo On Monday, 7 May 2018 22:32:00 UTC+8, mbanzon wrote: > > It was specifically stated that the code was CGO - this approach won’t > work unless there is a C compiler that is crosscompile enabled installed > already

Re: [go-nuts] How to fake os.Stdout in golang for testing?

2018-05-06 Thread alex . rou . sg
The output of text printed with the log as created in my example and fmt are exactly the same. The only change you would have to make is have a global log var and then do a simple search and replace all fmt.Printf to logVar.Printf. So the only argument you gave for not changing would be not wan

Re: [go-nuts] How to fake os.Stdout in golang for testing?

2018-05-05 Thread alex . rou . sg
Or use log instead of fmt var stdout = log.New(os.Stdout, "", 0) Then you can easily redirect it to any io.Writter like buf := &strings.Builder{} stdout = log.New(buf, "", 0) On Sunday, 6 May 2018 13:32:47 UTC+8, Lars Seipel wrote: > > On Sat, May 05, 2018 at 08:55:17AM -0700, mfried...@gmail

Re: [go-nuts] How to change the GBK with golang default charset?

2018-05-03 Thread alex . rou . sg
Go only has support for UTF-8, so you need to convert the file. e.g. package main import ( "fmt" "golang.org/x/text/encoding/simplifiedchinese" ) func main() { gbk := simplifiedchinese.GBK.NewDecoder() s, err := gbk.String("a\xfe\xfeb") if err != nil { panic(err)

[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

[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 *ba

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

[go-nuts] Re: Need help in in implementing a method on an interface

2018-04-24 Thread alex . rou . sg
Then just do type Generic struct{ name string } func (*Generic) GenericMethod() { fmt.Printf(name) } If you want to access name from p1 type Generic struct{ Name string } func (g *Generic) GenericMethod() { fmt.Printf(g.Name) } //package p1 func (x *P1data) F1() { x.Generic.Name = "as

[go-nuts] Re: Need help in in implementing a method on an interface

2018-04-24 Thread alex . rou . sg
If GenericMethod is truly the same, as in not even using the struct fields from P1data/P2data then there is a way. You just need to create a new struct type in package main that implements GenericMethod and then in packages p1 and p2 you embed the struct and thus expose the method. package main

[go-nuts] Re: CGO linker issues

2018-04-13 Thread alex . rou . sg
Have you already checked for another declaration in sm_sdk.h? btw which go version are you on? The error message doesn't seem like the latest release. Also can you provide a self contained buildable example and build commands? On Friday, 13 April 2018 12:45:39 UTC+8, r...@soulmachines.com wrote

[go-nuts] Re: Go Games

2018-03-13 Thread alex . rou . sg
Yup, as long as you build the go package as a c-shared you can basically do anything a C/C++ plugin can do. This contains a simple hello world for building a c-shared you can load in any C/C++ program. http://blog.ralch.com/tutorial/golang-sharing-libraries/ On Tuesday, March 13, 2018 at 4:15:2

[go-nuts] Re: Go Games

2018-03-13 Thread alex . rou . sg
To those talking about using game engines like unity etc... you can build go as c-shared and use it as a normal C/C++ plugin. The only thing to note is that you can't unload it without restarting the program and multiple c-shared go libraries wouldn't work together. As for what I'm using go for

Re: [go-nuts] What's the best way to maintain a package repository that have the major version in the import path?

2018-02-22 Thread alex . rou . sg
On Thursday, February 22, 2018 at 9:53:20 PM UTC+8, Axel Wagner wrote: > > Daisy chaining would mean I would only have to code API translations for >> the latest API but then it's debug hell and if one version in the chain >> breaks, >> it means fixing all the newer versions. Also there's a perf

Re: [go-nuts] What's the best way to maintain a package repository that have the major version in the import path?

2018-02-22 Thread alex . rou . sg
On Thursday, February 22, 2018 at 5:29:23 PM UTC+8, Axel Wagner wrote: > > Have you read https://research.swtch.com/vgo-import? It talks about > singletons and also how to solve that with different import paths. > Note, that this is also independent of *how* the different import paths > are repre

Re: [go-nuts] What's the best way to maintain a package repository that have the major version in the import path?

2018-02-21 Thread alex . rou . sg
I don't think changing the module name would be a good idea for singletons tho. And having a v0 has the added benefit of using newer codes while maintaining backwards compatible API. So no more backporting and all the mess of having multiple branches. On Thursday, February 22, 2018 at 1:49:53 P

[go-nuts] What's the best way to maintain a package repository that have the major version in the import path?

2018-02-21 Thread alex . rou . sg
vgo suggested that package developers put the major version into the import path e.g. foo/v1. However dealing with a VCS like git, this thought occur to me, what would it look like when the project needs to move from v1 to v2? In git we can rename the file in the entire history which messes thi

[go-nuts] How to use cflag -flto?

2018-02-19 Thread alex . rou . sg
So I'm trying to compile a test program with the cflag -flto and it failed to build with the message: > > cannot load DWARF output from $WORK/b001//_cgo_.o: decoding dwarf section > info at offset 0x0: too short I feel like I'm doing something wrong so I posed here instead of on github. Even t

[go-nuts] is it normal for buildmode=shared and buildmode=c-shared to be ok with building package main with no exported functions?

2018-01-28 Thread alex . rou . sg
Was looking through the issues tracker and saw someone having issues with trying to use buildmode=c-shared and I noticed he linked a package main with only a main function as the thing he is trying to build. So for lulz I tried building it with buildmode=c-shared followed by buildmode=shared an