Skip to content

Commit

Permalink
[FAB-15927] Better expression for golang
Browse files Browse the repository at this point in the history
Better for loop expression and veriable scope for golang

Signed-off-by: kukgini <kukgini@gmail.com>
Change-Id: I83a4ead246039b5b10334467f17c808465492725
  • Loading branch information
kukgini committed Jul 17, 2019
1 parent 61c33d3 commit 1387aa8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions chaincode/fabcar/go/fabcar.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,11 @@ func (s *SmartContract) initLedger(APIstub shim.ChaincodeStubInterface) sc.Respo
Car{Make: "Holden", Model: "Barina", Colour: "brown", Owner: "Shotaro"},
}

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])
i = i + 1
fmt.Println("Added", car)
}

return shim.Success(nil)
Expand Down

0 comments on commit 1387aa8

Please sign in to comment.