is it possible in golang extend struct (something like extend a class in other languages, and use it with functions for old one)
I have https://github.com/xanzy/go-gitlab/blob/master/services.go#L287 type SetSlackServiceOptions
package gitlab
// SetSlackServiceOptions struct
type SetSlackServiceOptions struct {
WebHook *string `url:"webhook,omitempty" json:"webhook,omitempty" `
Username *string `url:"username,omitempty" json:"username,omitempty" `
Channel *string `url:"channel,omitempty" json:"channel,omitempty"`
}
And I want to add some fields to the type in my own package. Is It possible to do it, that I can call function SetSlackService with this my own new type?
package gitlab
func (s *ServicesService) SetSlackService(pid interface{}, opt *SetSlackServiceOptions, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/services/slack", url.QueryEscape(project))
req, err := s.client.NewRequest("PUT", u, opt, options)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}
https://github.com/xanzy/go-gitlab/blob/266c87ba209d842f6c190920a55db959e5b13971/services.go#L297
Edit:
I want to pass own structure into function above. It's function from gitlab package and I want to extend the http request