【发布时间】:2017-07-27 09:26:49
【问题描述】:
这段代码运行良好:
feedService := postgres.FeedService{}
feeds, err := feedService.GetAllRssFeeds()
但是这段代码给了我错误:
feeds, err = postgres.FeedService{}.GetAllRssFeeds()
controllers\feed_controller.go:35: 无法调用指针方法 postgres.FeedService 文字控制器\feed_controller.go:35: 不能 取 postgres.FeedService 文字的地址
为什么这两段代码不相等?
这是一个结构声明:
type FeedService struct {
}
func (s *FeedService) GetAllRssFeeds() ([]*quzx.RssFeed, error) {
【问题讨论】:
-
"为什么这两段代码不相等?"因为语言规范是这么说的。错误消息是不言自明的,或者?
标签: go