go vet 警告 example 引用了未知标识符,但为什么呢?

Pie*_*rre 4 go

我有一个ExtractorPlaylist方法的接口:

// extractor.go
package extractor
type Extractor interface {
    Playlist(timestampFrom int64) (playlist.Tracklist, error)
}
Run Code Online (Sandbox Code Playgroud)

我在另一个包中使用这个接口:

// fip.go
package fip
type Extractor struct {
}

func (extractor Extractor) Playlist(timestampFrom int64) ([]playlist.Track, error) {
    // ...
}
Run Code Online (Sandbox Code Playgroud)

在我的测试中,我想展示一个有关如何使用Playlistfip包的方法的示例:

// fip_test.go
package fip
func ExamplePlaylist() { 
    // ...
}
Run Code Online (Sandbox Code Playgroud)

go vet显示此错误: fip/extractor_test.go:82:1: ExamplePlaylist refers to unknown identifier: Playlist

我不明白为什么...Playlist确实作为包中的方法存在fip。我缺少什么?

如果需要更多上下文,请参阅以下文件及其完整源代码:

https://github.com/coaxis/tizinger/blob/8016d52a1278cf44dde13d518c6a15a18cb29774/extractor/extractor.go

https://github.com/coaxis/tizinger/blob/8016d52a1278cf44dde13d518c6a15a18cb29774/fip/fip.go

https://github.com/coaxis/tizinger/blob/8016d52a1278cf44dde13d518c6a15a18cb29774/fip/fip_test.go

Mar*_*arc 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() { ... }
Run Code Online (Sandbox Code Playgroud)

您的示例是最后一种情况,其中TisExtractorMis Playlist