1 goland windows 点击Alt+Shift+Enter var _ someInterface =(*someStruct)(nil)
package main
type someInterface interface {
DoSomething()
DoAnotherThing()
}
type someStruct struct {}
//如何快速实现接口- how to quick implsomeInterface for someStruct,
//go语言没有implement关键字
// 1. imple someInterface for someStruct
// 2.
var _ someInterface =(*someStruct)(nil)
2 点击 截图中的implement或者Alt+Shift+Enter之后,自动生成结构体的方法,生成之后代码如下: var _ someInterface =(*someStruct)(nil)
package main
type someInterface interface {
DoSomething()
DoAnotherThing()
}
type someStruct struct {}
func (s someStruct) DoSomething() {
panic("implement me")
}
func (s someStruct) DoAnotherThing() {
panic("implement me")
}
//如何快速实现接口- how to quick implsomeInterface for someStruct,
//go语言没有implement关键字
// 1. imple someInterface for someStruct
// 2.
var _ someInterface =(*someStruct)(nil)
标签:someStruct,someInterface,nil,Shift,var,implement
From: https://www.cnblogs.com/heris/p/17233041.html