Golang function pointer as a part of a struct
I have the following code: type FWriter struct { WriteF func(p []byte) (n int,err error) } func (self *FWriter) Write(p []byte) (n int, err error) { return self.WriteF(p) } func MyWriteFunction(p []byte) (n int, err error) { // this function implements the Writer interface but is not named "Write" fmt.Print("%v",p) return len(p),nil } MyFWriter := new(FWriter) MyFWriter.WriteF = MyWriteFunction // I want to use MyWriteFunction with io.Copy io.Copy(MyFWriter,os.Stdin) What I am trying to do is to create a Writer interface to wrap MyWriteFunction because it is not named "Write" and I cant use it