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

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

鏈碼未生成-Go程序錯誤-無法引用未導出的名稱

鏈碼未生成-Go程序錯誤-無法引用未導出的名稱

Go
紫衣仙女 2021-03-30 17:19:23
在Ubuntu機器上構建go代碼時遇到錯誤。我檢查了GOPATH變量,一切似乎都很好。下面是我得到的錯誤的堆棧跟蹤:/ go / src / Chaincodeexample $ go build#_ / home / ubuntu / go / src / Chaincodeexample./Samplesupplychain.go:13:14: cannot refer to unexported name shim.logger./Samplesupplychain.go:91:5: syntax error: non-declaration statement outside function body下面是我的代碼:import("errors""fmt""encoding/json""github.com/hyperledger/fabric/core/chaincode/shim")var logger = shim.logger("my logger")//Create a struct for these 2 valuestype testuser struct{    Username string `json:"username"`    Fileuploaded string `json:"fileuploaded"`}//A function to create a user on the ledgerfunc CreateUser(stub shim.ChaincodeStubInterface, args []string) ([]byte, error){    if len(args) < 2 {        logger.Error("Invalid number of args")        return nil, errors.New("Expected atleast 1 argument for user creation")    }    var Username = args[0]    var UsernameInput = args[1]    //trying to understand    err := stub.PutState(Username, []byte(UsernameInput))    if err != nil {        logger.Error("Could not save new User to ledger", err)        return nil, err    }    var customEvent = "{eventType: 'UserCreation', description:" + Username + "' Successfully created'}"    err = stub.SetEvent("evtSender", []byte(customEvent))    if err != nil {        return nil, err    }    logger.Info("Successfully saved a supply chain user")    return nil, nil}func Checkuploadstatus(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {    logger.Debug("Entering supply-chain application")    if len(args) < 1 {        logger.Error("Invalid number of arguments")        return nil, errors.New("Missing details")    }    var Fileuploadedstatus = args[0]     bytes, err := stub.GetState(Fileuploadedstatus)     if err != nil {        logger.Error("Could not fetch Fileuploadedstatus with "+ Fileuploadedstatus +" from ledger", err)        return nil, err    }    return bytes, nil}給我想法解決這個問題。
查看完整描述

1 回答

?
楊魅力

TA貢獻1811條經(jīng)驗 獲得超6個贊

在Go中,只有其他包中的名稱以大寫字母開頭時,您才可以訪問它們。這有點像在Java或C ++中使用publicprivate。

呼叫您的類型Logger而不是logger它,它將起作用。


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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