本文整理匯總了Golang中structs.Index.ConnectKeywordDoc方法的典型用法代碼示例。如果您正苦於以下問題:Golang Index.ConnectKeywordDoc方法的具體用法?Golang Index.ConnectKeywordDoc怎麽用?Golang Index.ConnectKeywordDoc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類structs.Index
的用法示例。
在下文中一共展示了Index.ConnectKeywordDoc方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: crawl
func crawl(index *structs.Index, fileNames []string) {
// channel to recieve doc-keyword pairs.
c := make(chan DocKeywordPair)
// channel to count number of go-routines.
w := make(chan string)
semaphore := make(chan interface{}, MAX_FILES_OPEN)
goroutinesCount := len(fileNames)
for _, fileName := range fileNames {
go processFile(fileName, c, w, semaphore)
}
for goroutinesCount > 0 {
select {
case docKeywordPair := <-c:
index.ConnectKeywordDoc(docKeywordPair.Keyword,
docKeywordPair.Doc)
case name := <-w:
goroutinesCount--
percentage := (1.0 - float64(goroutinesCount)/float64(len(fileNames))) * 100
fmt.Printf("Processed file %v\t%6.2f%%\n", name, percentage)
}
}
}
示例2: connect
func connect(index *structs.Index, keyword string, doc string) {
index.ConnectKeywordDoc(keyword, doc)
fmt.Printf("%q and %q were connected in the index\n", keyword, doc)
}