我算是明白了,别说 go wire 了,勾八连 GO 这个语言能不能靠得住都挺难说的。既然如此,还是大胆一点吧。俗话说得好,所有让人难绷的细节都是为了宏观上的达成意图的方便。那就来吧。
22 lines
268 B
Go
22 lines
268 B
Go
package pasture
|
|
|
|
type Dog struct {
|
|
lines string
|
|
weapon string
|
|
}
|
|
|
|
func (d *Dog) Sound() string {
|
|
return d.lines
|
|
}
|
|
|
|
func (d *Dog) Dangers() bool {
|
|
if len(d.weapon) == 0 {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func NewDog(line string) *Dog {
|
|
return &Dog{lines: line}
|
|
}
|