I am using cgo to call the functions in cli driver. When i run the code i get goroutine problem i thing this is due to garbage collector unable to deallocate the memory allocated by the c. So how to solve this error.
The garbage collector can deallocate only Go pointers and basically the C code can do what it likes. I know that is not realy straightforward but i guess you can use a separate process to do this, procces that can be killed to free the memory.
Even better where to use the libraries functions to clean up.
A well designed library will provide you some functions to clean up after it. You have to take a look at the documentation of the library you are interfacing with.