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

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

Golang 中的緩沖區問題

Golang 中的緩沖區問題

Go
弒天下 2023-04-10 10:31:39
我正在處理多線程和序列化流程,并希望自動化我的偵察流程。只要我不調用名為nmap. 調用時nmap,它退出并出現以下錯誤:./recon-s.go:54:12: 調用 nmap 時參數不足 () want (chan<- []byte)這是我的代碼:package mainimport (    "fmt"    "log"    "os/exec"    "sync")var url stringvar wg sync.WaitGroupvar ip stringfunc nikto(outChan chan<- []byte) {    cmd := exec.Command("nikto", "-h", url)    bs, err := cmd.Output()    if err != nil {        log.Fatal(err)    }    outChan <- bs    wg.Done()}func whois(outChan chan<- []byte) {    cmd := exec.Command("whois",url)    bs, err := cmd.Output()    if err != nil {        log.Fatal(err)    }    outChan <- bs    wg.Done()}func nmap (outChan chan<-[]byte) {    fmt.Printf("Please input IP")    fmt.Scanln(&ip)    cmd := exec.Command("nmap","-sC","-sV","-oA","nmap",ip)    bs,err := cmd.Output()    if err != nil {    log.Fatal(err)    }    outChan <- bs    wg.Done()    }func main() {    outChan := make(chan []byte)    fmt.Printf("Please input URL")    fmt.Scanln(&url)    wg.Add(1)    go nikto(outChan)    wg.Add(1)    go whois(outChan)    wg.Add(1)    go nmap()    for i := 0; i < 3; i++ {        bs := <-outChan        fmt.Println(string(bs))    }    close(outChan)    wg.Wait()}
查看完整描述

1 回答

?
達令說

TA貢獻1821條經驗 獲得超6個贊

你得到的錯誤是:


調用 nmap 時參數不足 have () want (chan<- []byte)


這意味著nmap()方法main沒有任何參數,但實際nmap()定義需要一個參數chan<-[]byte,所以你必須從nmap()下面傳遞一個參數,我提到了你剛剛錯過的參數。


  func main() {

        outChan := make(chan []byte)


        fmt.Printf("Please input URL")

        fmt.Scanln(&url)

        wg.Add(1)

        go nikto(outChan)

        wg.Add(1)

        go whois(outChan) 

        wg.Add(1)

        go nmap(outChan) //you are just missing the argument here.

        for i := 0; i < 3; i++ {

            bs := <-outChan

            fmt.Println(string(bs))

        }


        close(outChan)

        wg.Wait()

    }


查看完整回答
反對 回復 2023-04-10
  • 1 回答
  • 0 關注
  • 141 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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