From 897f5bb96c64ce7798167a836ff3584b2c2acee1 Mon Sep 17 00:00:00 2001 From: kukgini Date: Tue, 9 Jul 2019 14:22:14 +0900 Subject: [PATCH] better loop expression for golang it's not an important thing. but i think it's more readable statement for golang developers. --- chaincode/fabcar/go/fabcar.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chaincode/fabcar/go/fabcar.go b/chaincode/fabcar/go/fabcar.go index 01792bf4..645ecee7 100644 --- a/chaincode/fabcar/go/fabcar.go +++ b/chaincode/fabcar/go/fabcar.go @@ -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 }