1- You may use
server := &EchoServer{}
instead of
server := EchoServer{}
A type may have a method set associated with it. The method set of an interface type is its interface. The method set of any other type
T
consists of all methods declared with receiver typeT
. The method set of the corresponding pointer type*T
is the set of all methods declared with receiver*T
orT
(that is, it also contains the method set ofT
). Further rules apply to structs containing anonymous fields, as described in the section on struct types. Any other type has an empty method set. In a method set, each method must have a unique non-blank method name.
And see: Pointer receiver and Value receiver difference in implementation with Iris framework
2- Or you may use
func (server EchoServer) Name() string {
return "EchoServer"
}
func (server EchoServer) Handle(method, params string) *Response {
return &Response{"OK", "Echo " + method + " " + params}
}
with
server := EchoServer{}