kankanSunaga / goss

0 stars 0 forks source link

外部ライブラリの構造体にたいしてレシーバメソッドを追加したいが、うまくできない #4

Closed kankanSunaga closed 4 years ago

kankanSunaga commented 4 years ago

https://github.com/KantaSunaga/goss/blob/feature/clone/Commands/create.go#L28 の戻り値といて返された構造体に、

https://github.com/KantaSunaga/goss/blob/feature/clone/Commands/create.go#L56 ↑をレシーバメソッドとして実行したいのですが、外部ライブラリの構造体を認識してくれません。

そうやるのが良いでしょうか?

d-kuro commented 4 years ago

これは仕様上できないという認識です。 その場合は一度

type Foo struct {
     repo git.Repository
}

func (f *Foo) Push() error {}

みたいに自前の type を経由してあげる必要があります