Sunday, June 23, 2024
HomeGolangIn an interface do I at all times have to jot down...

In an interface do I at all times have to jot down the signatures actually? – Getting Assist

If I wish to use an interface that complies with the signatures of an exterior bundle, say *template.Template, ought to I write all its signatures actually?

kind Tempi interface{
  AddParseTree(identify string, tree *parse.Tree) (*template.Template, error)
  Clone() (*template.Template, error)
  DefinedTemplates() string
  Delims(left, proper string) *template.Template

Is there a approach to inherit all of the signatures with a single assertion?

kind Tempi interface{

Tempi will clearly compile however it might probably solely be used as a kind constraint, I would like Tempi to inherit all of the signatures from *template.Template, is that this attainable?

Hi there there, if *template.Template is a struct, then so far as I do know, no. You possibly can’t cross it into the interface. But when it has interface description in exterior bundle, then you should utilize it to embed into your customized one with any additions you want.

1 Like



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments