invalid type for composite literal: Counter
If I remove the Counter{} argument, I get:
too few values in struct initializer
If I put Counter as an argument, I get:
type Counter is not an expression
Code:
Number in the beginning: 0
My value: 1
Increasing myself: 0
Increased number: 0
To fix the error in your factory function, try replacing Counter{} with nil.
Counter is an interface and not a concrete type, so you cannot construct instances of an interface like that.
Although I am not clear why your Number struct implements your Counter interface, as well as wanting to store a Counter interface field. That aspect has no relation to your desire to have a factory function and have a Counter interface field on your struct.
Justin
--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.