mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
better loop expression for golang
it's not an important thing. but i think it's more readable statement for golang developers.
This commit is contained in:
parent
3da5f8a450
commit
897f5bb96c
1 changed files with 3 additions and 3 deletions
|
|
@ -107,11 +107,11 @@ func (s *SmartContract) initLedger(APIstub shim.ChaincodeStubInterface) sc.Respo
|
|||
}
|
||||
|
||||
i := 0
|
||||
for i < len(cars) {
|
||||
for i, car := range cars {
|
||||
fmt.Println("i is ", i)
|
||||
carAsBytes, _ := json.Marshal(cars[i])
|
||||
carAsBytes, _ := json.Marshal(car)
|
||||
APIstub.PutState("CAR"+strconv.Itoa(i), carAsBytes)
|
||||
fmt.Println("Added", cars[i])
|
||||
fmt.Println("Added", car)
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue