建立用go编写的链码时出错

When I try to modify the example described in this hyperledger example I get some error when adding this external library in order to get the History of the chaincode state.
Why does that happen?

I add the library with govendor, but when I run this command:

docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n $CC_NAME -l "$LANGUAGE" -v 1.0 -c $INIT_STR -P "OR ('Org1MSP.member','Org2MSP.member')"

I get this error:

Error: Error endorsing chaincode:
rpc error: code = Unknown desc = error starting container: Failed to generate platform-specific docker build: Error returned from build: 2 "# firstExample chaincode/input/src/firstExample/firstStep.go:104:11: cannot assign *"github.com/hyperledger/fabric/protos/ledger/queryresult".KeyModification to kM (type *"firstExample/vendor/github.com/hyperledger/fabric/protos/ledger/queryresult".KeyModification) in multiple assignment chaincode/input/src/firstExample/firstStep.go:146:11: cannot assign *"github.com/hyperledger/fabric/protos/ledger/queryresult".KeyModification to kM (type *"firstExample/vendor/github.com/hyperledger/fabric/protos/ledger/queryresult".KeyModification) in multiple assignment chaincode/input/src/firstExample/firstStep.go:156:11: cannot assign *"github.com/hyperledger/fabric/protos/ledger/queryresult".KeyModification to kM (type *"firstExample/vendor/github.com/hyperledger/fabric/protos/ledger/queryresult".KeyModification) in multiple assignment

I have some troubles with this. I'm sure that the library is imported because if I build the chaincode written in go with the command:

go build 

I get no errors.
Please help me!

It's very hard to guess without seeing actual code which cause the compilation error, while it seems that you are not taking care of the second parameter which returned by HistoryQueryIteratorInterface#Next() API or even ChaincodeStubInterface#GetHistoryForKey(). Please see example of how to use those APIs correctly:

// GetPreviousValue reads previous value of given key
func (pm *personManagement) GetPreviousValue(params []string, stub shim.ChaincodeStubInterface) peer.Response {
    historyIer, err := stub.GetHistoryForKey(params[0])

    if err != nil {
        errMsg := fmt.Sprintf("[ERROR] cannot retrieve history of key <%s>, due to %s", params[0], err)
        fmt.Println(errMsg)
        return shim.Error(errMsg)
    }

    if historyIer.HasNext() {
        modification, err := historyIer.Next()
        if err != nil {
            errMsg := fmt.Sprintf("[ERROR] cannot read key record modification, key <%s>, due to %s", params[0], err)
            fmt.Println(errMsg)
            return shim.Error(errMsg)
        }
        fmt.Println("Returning information about", string(modification.Value))
        return shim.Success(modification.Value)
    }


    fmt.Printf("No history found for key %s
", params[0])
    return shim.Success([]byte(fmt.Sprintf("No history for key %s", params[0])))
}

NOTE: Please pay attention that historyIer.Next() returns history value and the error.