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

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

如果 go 模塊壞了怎么辦

如果 go 模塊壞了怎么辦

Go
汪汪一只貓 2023-05-08 16:25:25
作為 Node.js 開發(fā)人員,我對 Golang 還是個新手,并且在 Go 中的依賴管理方面苦苦掙扎。我正在使用 Go 1.11 并mod init在導(dǎo)入所有依賴項后應(yīng)用。其中之一是 logrus,它阻止我編譯我的 go 應(yīng)用程序。問題:我相信問題確實在 logrus 內(nèi)部,但是我不知道我現(xiàn)在如何獲得另一個(工作)版本的 logrus,以便我可以再次編譯我的應(yīng)用程序。/Users/redacted/Documents/redacted3/redacted2>Finished running tool: /usr/local/bin/go vet ./.../Users/redacted/go/pkg/mod/github.com/sirupsen/logrus@v1.2.0/entry.go:51: undefined: Logger/Users/redacted/go/pkg/mod/github.com/sirupsen/logrus@v1.2.0/entry.go:54: undefined: Fields/Users/redacted/go/pkg/mod/github.com/sirupsen/logrus@v1.2.0/entry.go:61: undefined: Level我怎樣才能擺脫這些煩人的依賴問題?相關(guān)進(jìn)口:log "github.com/sirupsen/logrus"Go.mod 包含github.com/sirupsen/logrus v1.2.0
查看完整描述

2 回答

?
Cats萌萌

TA貢獻(xiàn)1805條經(jīng)驗 獲得超9個贊

我不得不刪除/go/pkg/mod/github.com/...解決問題的路徑中的模塊。顯然在創(chuàng)建模塊或最初從 github 中提取代碼時出了點問題。

之后我go get再次使用我的 logrus lib,它按預(yù)期工作。


查看完整回答
反對 回復(fù) 2023-05-08
?
嗶嗶one

TA貢獻(xiàn)1854條經(jīng)驗 獲得超8個贊

  • 我認(rèn)為 logrus 模塊很好,您只是缺少“l(fā)og.WithFields”定義。

  • main.go 文件:

//Source : https://github.com/sirupsen/logrus

//logrus version : require github.com/sirupsen/logrus v.1.2.0

//go version go1.11.2 linux/amd64



package main


import (

//Go package

"os"

"fmt"

log "github.com/sirupsen/logrus"

)


//Checking if the logout file exist

//Just to show the Fatal tag.

func Exists(name string) bool {

? ? ? ? _, err := os.Stat(name)

? ? ? ? return !os.IsNotExist(err)

}



func main() {

? ? ? ? fmt.Println("I'am the main here ... all begin ...")?


? ? ? ? log.WithFields(log.Fields{"main": "main process",}).Info("Initialization.")

? ? ? ? log.WithFields(log.Fields{"main": "...some codes....",}).Warn("Nothting here yet.")


? ? ? ? log.WithFields(log.Fields{"main":"main process",}).Info("It's done. Thanks.")


? ? ? ? //The check here (it's just for demo) so you can see the others tags

? ? ? ? if Exists("paht/to/mylogoutfile") == false {

? ? ? ? ? ? ? ? log.WithFields(log.Fields{"main": "Checking logoutputfile path.",}).Fatal("Mising the Logout file.")

}


? ? ? ? //fmt.Println("This is the end Thankyou for using this. :) ")

? ? ? ? }

go.mod 文件:


module logrustest


require github.com/sirupsen/logrus v1.2.0 // indirect

輸出 :

http://img1.sycdn.imooc.com/6458b21b0001c5d106260083.jpg

查看完整回答
反對 回復(fù) 2023-05-08
  • 2 回答
  • 0 關(guān)注
  • 178 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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