第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

GOLANG: Walk Directory Tree and Process Files

GOLANG: Walk Directory Tree and Process Files

Go
函數(shù)式編程 2021-07-07 17:50:45
我正在編寫一個(gè)例程來遍歷目錄樹并為我找到的每個(gè)文件創(chuàng)建一個(gè)數(shù)字簽名(salted-hash)。在測試它時(shí),我得到了這種奇怪的行為 - 如果我給程序一個(gè)目錄“上方”的根路徑,程序可以遍歷樹并打印出文件名,但是如果我嘗試打開文件以讀取它的字節(jié),我在例程找到的文件上獲取錯(cuò)誤消息“沒有這樣的文件或目錄” - 不確定這里給出了什么。Walk() 例程如何“看到”文件,但 ioutil.ReadFile() 無法找到它?示例代碼:// start with path higher up the tree, say $HOMEfunc doHashWalk(dirPath string) {    err := filepath.Walk(dirPath, walkFn)    // Check err here}func walkFn(path string, fi os.FileInfo, err error) (e error) {    if !fi.IsDir() {        // if the first character is a ".", then skip it as it's a hidden file        if strings.HasPrefix(fi.Name(), ".") {            return nil        }        // read in the file bytes -> get the absolute path        fullPath, err := filepath.Abs(fi.Name())        if err != nil {            log.Printf("Abs Err: %s", err)        }        // THIS ALWAYS FAILED WITH ERROR        bytes, err := ioutil.ReadFile(fullPath) // <-- (fi.Name() also doesn't work)        if err != nil {            log.Printf("Err: %s, Bytes: %d", err, len(bytes))             }        // create the salted hash        ...    }    return nil}
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 323 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)