亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

go vet 警告該示例引用未知標識符,但為什么呢?

go vet 警告該示例引用未知標識符,但為什么呢?

Go
小怪獸愛吃肉 2022-06-13 15:54:48
我有一個Extractor接口,它有一個Playlist方法:// extractor.gopackage extractortype Extractor interface {    Playlist(timestampFrom int64) (playlist.Tracklist, error)}我在另一個包中使用這個接口:// fip.gopackage fiptype Extractor struct {}func (extractor Extractor) Playlist(timestampFrom int64) ([]playlist.Track, error) {    // ...}在我的測試中,我想展示一個關于如何使用該Playlist方法的示例fip:// fip_test.gopackage fipfunc ExamplePlaylist() {     // ...}但go vet顯示此錯誤: fip/extractor_test.go:82:1: ExamplePlaylist refers to unknown identifier: Playlist我不明白為什么......Playlist確實作為fip包中的一種方法存在。我錯過了什么?
查看完整描述

1 回答

?
ITMISS

TA貢獻1871條經驗 獲得超8個贊

示例函數的正確名稱ExampleExtractor_Playlist如測試文檔的示例部分所述。


報價:


The naming convention to declare examples for the package, a function F, a type T and method M on type T are:


func Example() { ... }

func ExampleF() { ... }

func ExampleT() { ... }

func ExampleT_M() { ... }

您的示例是最后一種情況TisExtractor和Mis Playlist。


查看完整回答
反對 回復 2022-06-13
  • 1 回答
  • 0 關注
  • 148 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號