Your mistake, unfortunately, is somewhat misleading. The problem is that this is an instance method, and you call it as if it were a package method.
You need something like this:
func main() { var in []byte jp := JSONParser{} actual, err2 := jp.Parse(in) }
I assume that the error is formulated as follows, because the receiver (thing in parens on the left site of the function name) is treated like any other argument passed to the function in the background.
If you want to call your method this way, the definition will be just func Parse(toParse []byte) ([]Schema, int) , and if it were in a package called JSONParser , that would be the correct syntax. If it was defined in the same package as in your example, you simply name it as Parse(in)
source share