I am trying to build chaincode using hyperledger. I am using GoLang to write the contract, while building the contract i am facing the below error :
cannot refer to unexported name shim.success
undefined: shim.success
There may be few variable undefined errors. As My code is not getting build, I am unable to debug the code. Please find my code which i am using. I am unable to find the reason for the above error. Please help me in resolving this issue.
import (
"encoding/json"
"fmt"
"bytes"
"time"
"strings"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
)
func (t *check) SurrenderSaves(stub shim.ChaincodeStubInterface,
args []string) pb.Response {
fmt.Println("Entering CodeSurrenderSaves")
var err error
var lastImportDatekey string
var lastImportDate []byte
lastImportDate, err= stub.GetState("lastImprtDatesaved")
fmt.Println("lastImportDate ...... ", lastImportDate)
err = json.Unmarshal(lastImportDate, &lastImportDatekey)
if err != nil {
fmt.Printf("Unable to unmarshal lastImportDate input
lastImportDatekey: %s\n", err)
return shim.Error(err.Error())
}
fmt.Println("lastImportDatekey ...... ", lastImportDatekey)
if (lastImportDate == nil){
currentTime := time.Now()
var timeString = currentTime.Format("2006-01-02")
lastImportDatekey = timeString
fmt.Println("lastImportDatekey ...... ", lastImportDatekey)
} else {
err = json.Unmarshal(lastImportDate, &lastImportDatekey)
if err != nil {
fmt.Printf("Unable to unmarshal lastImportDate input
lastImportDate: %s\n", err)
return shim.Error(err.Error())
}
fmt.Println(" lastImportDatekey end:",lastImportDatekey)
}
return shim.Success(nil)
}
func (t *check) Init(stub shim.ChaincodeStubInterface) pb.Response {
fmt.Println("Initiate the chaincde")
return shim.Success(nil)
}
func (t *check) Invoke(stub shim.ChaincodeStubInterface) pb.Response
{
function, args := stub.GetFunctionAndParameters()
if function == "SurrenderSaves" {
return t.SurrenderSaves(stub, args)
}
fmt.Println("Function not found")
return shim.Error("Received unknown function invocation")
return nil, nil
}