Re: [go-nuts] Re: WebAssembly: Auto-generating Go bindings for javascript/DOM from the Web Standards.

2019-02-24 Thread Paul Jolly
> > I have started to work on DOM binding based on WebIDL and a binding > generator. I don't have full WebIDL support yet, but it does process idl > from about 80 specifications. See https://gowebapi.github.io for more > details. > Hi Martin, I'd like to second Tyler's suggestion that you start

Re: [go-nuts] Memory corruption with GOGC=on

2019-02-24 Thread robert engels
With GC off the free will not be called, nor will destructors be executed in response to finalizers, so many memory corruption errors will not be experienced (nor detected). Almost certainly the C memory is not being managed correctly - possibly copying a pointer between structs and then

Re: [go-nuts] Re: Unmarshal nested XML value from dynamic XML document

2019-02-24 Thread Steffen Wentzel
Very nice, `xml:",any"` was doing the trick. I've condensed the function and here's the (currently) final result: https://play.golang.org/p/G1eGw5gtk7C func id3(axl []byte) string { type Return struct { Response struct { Return string `xml:"return"` } `xml:",any"` } var ret Return err :=

[go-nuts] Memory corruption with GOGC=on

2019-02-24 Thread yangwuist
HI all, Error unexpected fault address might be triggered by data race or memory corruption. After code review, I suspected the reasin is memory corruption instead of the data race. The following code panics occasionally, and yes, when I initialized silces. package controlcan import "C"

Re: [go-nuts] Re: Unmarshal nested XML value from dynamic XML document

2019-02-24 Thread Matt Harden
You don't have to use an xml.Decoder. You may be able to use the `xml:",any"` tag for this case. type Response struct { XMLName xml.Name Return string `xml:"return"` } type Outer struct { XMLName struct{} `xml:"outer"` Responses []Response `xml:",any"` }

[go-nuts] Re: Resolving methods on pointer types

2019-02-24 Thread Tamás Gulácsi
Type is also a method set. So even if two types have equal underlying types, their method sets (the methods defined on them) are different. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

[go-nuts] Re: runtime CallerFrames and FuncForPC miss some infomation

2019-02-24 Thread qiaojiawei-star
thanks for replay, you said right, i have changed the code, its works fine, thank you, here is code: package main import ( "fmt" "runtime" ) func test() { var zero = 0 _ = 1 / zero } func Stack() { var pc [16]uintptr n := runtime.Callers(0, pc[:]) fmt.Println(n, pc) callers := pc[:n] frames

[go-nuts] Re: Resolving methods on pointer types

2019-02-24 Thread rojer9
hi Jake On Sunday, February 24, 2019 at 11:27:10 PM UTC, Jake Montgomery wrote: > > Maybe I'm misunderstanding, but the important thing is that foo never be > copied. In your example, it is, in fact, *not *copied. See > https://play.golang.org/p/U5EsDZSO3ce. Note that Foo is copied, but both >

[go-nuts] Re: Resolving methods on pointer types

2019-02-24 Thread jake6502
Maybe I'm misunderstanding, but the important thing is that foo never be copied. In your example, it is, in fact, *not *copied. See https://play.golang.org/p/U5EsDZSO3ce. Note that Foo is copied, but both f2 and f3 contain the same foo pointer, so the foo was never copied or moved. When

Re: [go-nuts] Re: Resolving methods on pointer types

2019-02-24 Thread Burak Serdar
On Sun, Feb 24, 2019 at 3:34 PM wrote: > > thanks for the suggestion Burak and Jake, however embedding won't do for the > same reason as aliasing - it allows copying by value, which i want to prevent > (in my real use case foo.bar is a C pointer). You could make it 2-layers, with the pointer

[go-nuts] Re: Resolving methods on pointer types

2019-02-24 Thread rojer9
thanks for the suggestion Burak and Jake, however embedding won't do for the same reason as aliasing - it allows copying by value, which i want to prevent (in my real use case foo.bar is a C pointer). https://play.golang.org/p/4BcOQTGkPiy works, and it should not (f3 := *f2 is a no as it makes

[go-nuts] Re: Resolving methods on pointer types

2019-02-24 Thread jake6502
On Sunday, February 24, 2019 at 4:31:10 PM UTC-5, Deomid Ryabkov wrote: > > Why can't Go resolve methods declared on the pointer receiver of the > destination type? > Because that is not how the language was designed. (I'm too busy to look up the spec here, but it is in there.) > > consider:

Re: [go-nuts] Resolving methods on pointer types

2019-02-24 Thread rojer9
On Sunday, February 24, 2019 at 9:36:07 PM UTC, rog wrote: > > Foo is declared as a new type, and no methods are declared on that that > type. If you had declared: > > type Foo = *Foo > > it would have been a different matter. > true. however, i don't want a type alias because that would

Re: [go-nuts] Resolving methods on pointer types

2019-02-24 Thread roger peppe
Foo is declared as a new type, and no methods are declared on that that type. If you had declared: type Foo = *Foo it would have been a different matter. On Sun, 24 Feb 2019, 10:30 pm , wrote: > Why can't Go resolve methods declared on the pointer receiver of the > destination type? > >

[go-nuts] Resolving methods on pointer types

2019-02-24 Thread rojer9
Why can't Go resolve methods declared on the pointer receiver of the destination type? consider: type foo struct{ bar int } type Foo *foo func (f *foo) GetBar() int { return f.bar } func NewFoo(bar int) Foo { return {bar: bar} } func main() { f1 := {bar: 123} fmt.Printf("%d\n", f1.GetBar())

Re: [go-nuts] Re: Unmarshal nested XML value from dynamic XML document

2019-02-24 Thread Sam Whited
Your function appears to return error text, but it will be much more clear what's going on when reading the code if you encode your intent in the return type and return an error instead of a string (which gives me no information about what that string is supposed to represent: is it an error?

[go-nuts] Re: Unmarshal nested XML value from dynamic XML document

2019-02-24 Thread Steffen Wentzel
Thanks for the response. I was hoping it would be possible with just xml.Unmarshal. I now have this implementation - any comments on that? (I'm okay with returning the error inline, it's just for logging purposes): Playground: https://play.golang.org/p/6J8XndWdlv_N func id2(axl []byte) string

[go-nuts] Re: WebAssembly: Auto-generating Go bindings for javascript/DOM from the Web Standards.

2019-02-24 Thread Martin Juhlin
Hi, I have started to work on DOM binding based on WebIDL and a binding generator. I don't have full WebIDL support yet, but it does process idl from about 80 specifications. See https://gowebapi.github.io for more details. Martin Den fredag 28 december 2018 kl. 13:16:22 UTC+1 skrev Chris