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:
kukgini 2019-07-09 14:22:14 +09:00 committed by GitHub
parent 3da5f8a450
commit 897f5bb96c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}