# Doesn't match Google Go

**URL:** https://talk.remobjects.com/t/doesnt-match-google-go/22024
**Category:** Gold
**Created:** [May 16, 2020, 10:51am UTC](https://talk.remobjects.com/t/doesnt-match-google-go/22024 "2020-05-16T10:51:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![davidj](https://talk.remobjects.com/user_avatar/talk.remobjects.com/davidj/32/12824_2.png) [@davidj](https://talk.remobjects.com/u/davidj)
#### Post date: [May 16, 2020, 10:51am UTC](https://talk.remobjects.com/t/doesnt-match-google-go/22024/1 "2020-05-16T10:51:50Z")

</div>

I’m trying to understand what Elements-Go is.

I put a simple Go program into Water, compiling to CLR, and the output is not correct.

> package RemTest1
> 
> import (  
> “fmt”  
> )
> 
> type User struct {  
> name String  
> }
> 
> func (user User) String() String {  
> return fmt.Sprintf(“User: name = %s”, user.name)  
> }
> 
> func main() {  
> user := User{name: “foo”}  
> fmt.Println(user) // User: name = foo  
> }

In Google Go, this program outputs “User: name = foo”

In Water, compiling for CLR, this program outputs “{foo}”

I’m not exactly surprised by this, because CLR doesn’t support row polymorphic structural typing, but what is happening here is _not_ Google Go. It seems more like a transpiler that maps Go constructs into CLR objects that behave like CLR objects, not Go objects (which is not going to work to actually run existing Go code).

Which begs the question… What is the goal of Elements-Go?

Is it intending to be compatible with Google Go? And if so, why doesn’t this simple program work? (i.e. seems like you should have some basic structural typing test cases)

And if it’s not intending to be compatible with Google Go, what is it for?

One way to make Go objects run correctly on CLR might be to declare all the types “dynamic” and let CLR do dynamic dispatch. That would create the duck-type like behavior of structural-subtyping. Though given that the above simple program doesn’t work like Go, I’m suspicious of whether the Elements Go compiler is doing Go compatible row-polymorphic structural type-inference.

You can see my broader related question here…

> [@What is the memory/type model? and why doesn't the website explain it?](https://talk.remobjects.com/t/what-is-the-memory-model-and-why-doesnt-the-website-explain-it/22021):
>
> I just landed on this website today… I’m reading about this elements compiler environment decoupling languages and platforms, and the obvious unanswered question is… what the heck is the memory model / GC / typing / runtime situation for this cross-compiling? and why doesn’t the website say anything about it? Is Swift on windows an ARC system talking to a .NET runtime? Is it compiling swift into CLR? Is C# on Cocoa running on a GC runtime? Or is it C# with ARC? Does it ARC all C# objects? Is …

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [May 16, 2020, 12:41pm UTC](https://talk.remobjects.com/t/doesnt-match-google-go/22024/2 "2020-05-16T12:41:59Z")

</div>

> [@davidj](#):
>
> In Google Go, this program outputs “User: name = foo”
> 
> In Water, compiling for CLR, this program outputs “{foo}”

I’ll need to have someone form the compiler team to have a look at this one Monday; On first sight (but i’m not the Go expert, myself), this looks like it should work. It seem that String() maybe does not correctly get mapped to .NET’s .ToString() under the hood, but we’ll have to see. Thanx for reporting this!

—marc

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [May 16, 2020, 12:42pm UTC](https://talk.remobjects.com/t/doesnt-match-google-go/22024/3 "2020-05-16T12:42:04Z")

</div>

Thanks, logged as [bugs://84311](https://www.remobjects.com/portal/bugs/?id=84311)
