gpt4 book ai didi

转到错误 : continue is not in a loop

转载 作者:数据小太阳 更新时间:2023-10-29 03:47:08 25 4
gpt4 key购买 nike

我已经编写了带有 for 循环的 go 代码,代码如下。但是当我构建代码时,我得到“continue is not within loop”。我不明白为什么会这样。请帮忙

去版本:

go version go1.7.5 linux/amd64

完整代码在下面的链接 https://pastebin.com/0ZypMYVK

引用截图 enter image description here

for k:=0;k < len(args);k++{
fmt.Println("k is ", k)
hsCode := args[k]
lenChk:=checkHashLen(hsCode)
if lenChk==false {
fmt.Println("Length should be 32" )
continue
}
codeBytes,_ := json.Marshal(hsCode)

APIstub.PutState(strconv.FormatInt(makeTimestamp(),10), codeBytes)
fmt.Println("Added: ", k)
}

错误 enter image description here

./hashcode.go:88: continue is not in a loop

最佳答案

你的问题在这里:

//push single code on the block
func (s *SmartContract) pushCode(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {

hsCode := args[0]
lenChk := checkHashLen(hsCode)
if lenChk == false {
fmt.Println("Length should be 32")
continue
}
codeBytes, _ := json.Marshal(hsCode)
APIstub.PutState(strconv.FormatInt(makeTimestamp(), 10), codeBytes)
return shim.Success(nil)
}

该错误说明出了什么问题。您在不在 for 循环中时使用关键字 continue,此函数不包含 for 循环。

initCodeLedger 包含一个 for 循环,因此您会因此而分心,但这不是错误中没有给出的行,它位于第 86/87/88 行附近。如果问这样的问题,最好在 play.golang.org 上发布代码。

关于转到错误 : continue is not in a loop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45727904/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com