[go-nuts] reflect, is it possible to get the [body + sign] of a func as text at runtime ?

2016-09-18 Thread 'Mihai B' via golang-nuts
The body is compiled so you can't get it via reflection.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Interface{} constrains on specific types

2016-06-24 Thread 'Mihai B' via golang-nuts
 I'm developing a json schema generator (json schema from Go ast and the 
other way around). There is a keyword "oneOf" which requires  exactly one 
schema to be valid in this keyword's value. In Go I translate it by using 
an empty interface{}. The issue is that when I convert the interface{} to 
json schema I can only say that the object can be of any type even if I 
know that it can hold only a small subset.
 Therefore I'm wondering if placing some constrains on the types that could 
be implemented by the interface would be a good idea. For example instead 
of `type interface{}` which implements any type we could define the types 
it can implement (e.g.  type  X interface{T1, T2, T3} ). This way we don't 
have a totally black box so it improves the documentation/semantics and we 
avoid specific bugs using static analysis. Currently the practice seems to 
be documenting the types in pure comments[0] which cannot be analysed 
statically. Another option that I'm considering now is to use the empty 
interface but with specific tags [1] and use an external tool. This might 
have been proposed before but I can't find it on the mailing list. What do 
you think?

[0]  https://golang.org/pkg/go/ast/#Object 
[1]  

type Object struct {
Name string   // declared 
name
Decl interface{} `interface:"Field,FuncDecl,LabeledStmt,external.Scope" 
//
   
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Unmarshalling and tags

2016-06-19 Thread 'Mihai B' via golang-nuts
Hi there,

I have a struct that needs to be marshalled/unmarshalled using various 
serialization formats(xml, json, name/value). The tags start to represent a 
considerable effort[0] so I'm wondering if this is a common use case and if 
a change[1] to the encoding packages to specify the tag key/selectors would 
be a bad idea. Another option would be to use a standard tag key as default 
(e.g. "encoding") but I think it may violate  the Go1 backward 
compatibility.

Mihai.


[0]
type Payment struct {
ActionType paypal.ActionType `query:"actionType,omitempty" 
json:"actionType,omitempty"  xml:"actionType,omitempty"`
ReceiverList paypal.ReceiverList `query:"actionType,omitempty" 
json:"receiverList,omitempty"  xml:"receiverList,omitempty"`
}


[1] (dec *Decoder)SetTagKey(key string)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] WebAssembly as a target

2016-06-19 Thread 'Mihai B' via golang-nuts
I don't think we can expect anything before wasm supports GC (i.e. Phase 3 on 
wasm roadmap). Once GC is supported(not very soon) Go could be compiled through 
llgo[0]. One issue could be the binary size(.i.e due /reflect)

- Mihai
[0] https://llvm.org/svn/llvm-project/llgo/trunk/README.TXT

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.