I was trying to understand the Interface embedding with the following code.
I have the following:
type MyprojectV1alpha1Interface interface {
RESTClient() rest.Interface
SamplesGetter
}
// SamplesGetter has a method to return a SampleInterface.
// A group's client should implement this interface.
type SamplesGetter interface {
Samples(namespace string) SampleInterface
}
// SampleInterface has methods to work with Sample resources.
type SampleInterface interface {
Create(*v1alpha1.Sample) (*v1alpha1.Sample, error)
Update(*v1alpha1.Sample) (*v1alpha1.Sample, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1alpha1.Sample, error)
List(opts v1.ListOptions) (*v1alpha1.SampleList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Sample, err error)
SampleExpansion
}
Now if I have the follwoing:
func returninterface() MyprojectV1alpha1Interface {
//does something and returns me MyprojectV1alpha1Interface
}
temp := returninterface()
Now, from the MyprojectV1alpha1Interface if I want to call the
Create function of SampleInterface
what I need to do?
Also, please explain me how this interfaces work in Golang.