文件名称:Fanout.zip
文件大小:9KB
文件格式:ZIP
更新时间:2022-08-08 01:49:18
开源项目
Fanout 可以让编写平行代码更加容易。Fanout 的代码是可以重复使用的,所以你可以很容易地就写下平行代码,而不用担心 fatal error: all goroutines are asleep - deadlock!示例代码:for _, word := range domainWords { if strings.TrimSpace(word) == "" { continue } py := pinyin.Convert(word) pydowncase := strings.ToLower(py) domain := pydowncase ".com" outr, err := domainAvailable(word, domain) if err != nil { fmt.Println("Error: ", err) continue } if outr.available { fmt.Printf("[Ohh Yeah] %s %s\n", outr.word, outr.domain) continue } fmt.Printf("\t\t\t %s %s %s\n", outr.word, outr.domain, outr.summary) } type checkResult struct { word string domain string available bool summary string } func domainAvailable(word string, domain string) (ch checkResult, err error) { var summary string var output []byte ch.word = word ch.domain = domain cmd := exec.Command("whois", domain) output, err = cmd.Output() if err != nil { fmt.Println(err) return } outputstring := string(output) if strings.Contains(outputstring, "No match for \"") { ch.available = true return } summary = firstLineOf(outputstring, "Registrant Name") " => " summary = summary firstLineOf(outputstring, "Expiration Date") ch.summary = summary return } 标签:Fanout
【文件预览】:
fanout-master
----LICENSE(10KB)
----README.md(7KB)
----parallel_test.go(2KB)
----parallel.go(4KB)