此代码工作正常:呼叫结构方法
feedService := postgres.FeedService{}
feeds, err := feedService.GetAllRssFeeds()
但这个代码给我错误:
feeds, err = postgres.FeedService{}.GetAllRssFeeds()
controllers\feed_controller.go:35: cannot call pointer method on postgres.FeedService literal controllers\feed_controller.go:35: cannot take the address of postgres.FeedService literal
为什么这两段代码不等于?
这里是一个结构声明:
type FeedService struct {
}
func (s *FeedService) GetAllRssFeeds() ([]*quzx.RssFeed, error) {
“为什么这两段代码不相等?”因为语言规范是这样说的。错误信息是非常明显的,或? – Volker