go - Set a parameter as an interface or a list of interfaces -


I am doing a lot to go and there are some goodies which I have not yet received

For example, I have a function that can be called in such a way:

Avatar myVar.InitOperation ("foo", operator.acqual, "bar") myVar.InitOperation ( "Foo", include operator, [] interface {} baz ", 1," boo "} myVar.InitOperation (" foo ", operator.GREATER_THAN, 1)

: < / P>

  func InitOperation (attr string, operator operator, value interface {}) {if operator.String () == "bar" {doSomething (attr, Operator, value)} and if (operator.string () == "include" {doSomethingElse (atri, operator, value)} // and in similar case}  

The thing is that when I pass a string or an integer, it goes well, but when I pass through an array, it is parsed as an element.

In my function doSomethingElse , I get the value of value , and you seem to be y as a mother, I have an error

OK, May include only value as [] interface {} and interface {} will not set. Here, everything goes well, but when I'm calling doSomething , it is parsed as [[myValue]] which is logical, But I do not expect.

My question is, is there any way to pass any [] interface {} or interface {}? Can be red in or in the form of an array of values, for the case?

Thank you!

You need to make a type of claim:

  func InitOperation (attr string, operator operator, value interface {}) {operator.string () == "bar" {doSomething (operator, operator, value)} and if (operator.STRING) == "included" {doSomethingElse ( Func doSomethingElse (entry string, operator operator, value [] interface {}) {for _, V: = class value {}}, enter, operator, value ([] interface {})) // and in similar case { Fmt.println (v)}}  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -