下一個實現接口方法的方法是否正確? (getKey
,getData
)接口的方法
type reader interface {
getKey(ver uint) string
getData() string
}
type location struct {
reader
fileLocation string
err os.Error
}
func (self *location) getKey(ver uint) string {...}
func (self *location) getData() string {...}
func NewReader(fileLocation string) *location {
_location := new(location)
_location.fileLocation = fileLocation
return _location
}
事實上,不把'reader'實際上只是給''location'類型添加一個匿名成員,佔用空間不做任何有用的事情? – matthias 2012-08-31 17:20:09