mercredi 13 mars 2019

How to adapt test function into normal one

I am having a problem trying to compile a go program using an adapted test function (I just removed the * testing), I get this error, but I can't figure out where the adress or nul pointer error come from. Ideas ??

func TestRetrieveOK() {
    // Check if the Archive table is initialized or not
    err := checkAndInitDatabase()
    if err != nil {
        println(err.Error())

    }

    // Variable that defines the ArchiveService
    var archiveService *ArchiveService
    // Create the Archive Service
    service := archiveService.CreateService()
    archiveService = service.(*ArchiveService)
    // Variable that defines the ArchiveService
    var objectType = ObjectType{Area:UShort(2),Service: UShort(3),Version: UOctet(1),Number:  UShort(COM_VALUE_OF_SINE_TYPE_SHORT_FORM),
    }
    var identifierList = IdentifierList([]*Identifier{NewIdentifier("fr"), NewIdentifier("cnes"), NewIdentifier("archiveservice"), NewIdentifier("test")})
    var longList = LongList([]*Long{NewLong(0)})

    // Variables to retrieve the return of this function
    var archiveDetailsList *ArchiveDetailsList
    var elementList ElementList
    var errorsList *ServiceError
    // Start the consumer
    archiveDetailsList, elementList, errorsList, err = archiveService.Retrieve(providerURL, objectType, identifierList, longList)
    if errorsList != nil || err != nil || archiveDetailsList == nil || elementList == nil {
        println(errorsList)

    }
    for i := 0; i < elementList.Size(); i++ {
        fmt.Println(elementList.GetElementAt(i))
    }
}

This function calls an API that retrieves values in a database stored locally. I am getting the following error :

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x80 pc=0xd6ce64]

goroutine 5 [running]:
ccsdsmo-malgo/mal/api.(*ClientContext).TransactionId(...)
    /home/tom/go/src/ccsdsmo-malgo/mal/api/context.go:135
ccsdsmo-malgo/mal/api.(*ClientContext).NewInvokeOperation(...)
    /home/tom/go/src/ccsdsmo-malgo/mal/api/operations.go:420
ccsdsmo-malgo-examples/archiveservice/archive/consumer.createInvokeConsumer(0xc000106080, 0x1, 0xc000048a80, 0x7fed040a7d98, 0x0)
    /home/tom/go/src/ccsdsmo-malgo-examples/archiveservice/archive/consumer/consumer.go:119 +0x34
ccsdsmo-malgo-examples/archiveservice/archive/consumer.StartRetrieveConsumer(0xc000106080, 0x1000100030002, 0xc00011a020, 0x4, 0x4, 0xc000104018, 0x1, 0x1, 0xc0000f8010, 0xc000048a80, ...)
    /home/tom/go/src/ccsdsmo-malgo-examples/archiveservice/archive/consumer/consumer.go:188 +0x3c
ccsdsmo-malgo-examples/archiveservice/archive/service.(*ArchiveService).Retrieve(0xc0000bff88, 0x12a3d0f, 0x18, 0x1000100030002, 0xc00011a020, 0x4, 0x4, 0xc000104018, 0x1, 0x1, ...)
    /home/tom/go/src/ccsdsmo-malgo-examples/archiveservice/archive/service/archiveservice.go:105 +0x1a8
main.TestRetrieveOK()
    /home/tom/go/src/ccsdsmo-malgo-examples/GUI/main.go:369 +0x308
main.main.func4.1()
    /home/tom/go/src/ccsdsmo-malgo-examples/GUI/main.go:113 +0x20
created by main.main.func4
    /home/tom/go/src/ccsdsmo-malgo-examples/GUI/main.go:112 +0x35
exit status 2

Aucun commentaire:

Enregistrer un commentaire