mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
Improve unmarshalling in asset-transfer-basic Go cc
Although the current code works thanks to Go being quite forgiving when it comes to pointers, it doesn't exhibit the best coding style. This patch addresses this. Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
This commit is contained in:
parent
e51dfb9bce
commit
ee2df4ba6a
1 changed files with 4 additions and 4 deletions
|
|
@ -82,13 +82,13 @@ func (s *SmartContract) ReadAsset(ctx contractapi.TransactionContextInterface, i
|
|||
return nil, fmt.Errorf("the asset %s does not exist", id)
|
||||
}
|
||||
|
||||
var asset *Asset
|
||||
var asset Asset
|
||||
err = json.Unmarshal(assetJSON, &asset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return asset, nil
|
||||
return &asset, nil
|
||||
}
|
||||
|
||||
// UpdateAsset updates an existing asset in the world state with provided parameters.
|
||||
|
|
@ -173,12 +173,12 @@ func (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var asset *Asset
|
||||
var asset Asset
|
||||
err = json.Unmarshal(queryResponse.Value, &asset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
assets = append(assets, asset)
|
||||
assets = append(assets, &asset)
|
||||
}
|
||||
|
||||
return assets, nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue