Advance Golang TestGetProduct() function

func TestGetProduct(t *testing.T) {
	addProduct("keyboard", 100, 5001.00)
	request, err := http.NewRequest("GET", "/product/1", nil)
	if err != nil {
	} else {
		log.Println("no error")
	response := sendRequest(request)
	checkStatusCode(t, http.StatusOK, response.Code)

func sendRequest(request *http.Request) *httptest.ResponseRecorder {
	recorder := httptest.NewRecorder()
	a.Router.ServeHTTP(recorder, request)
	return recorder

func checkStatusCode(t *testing.T, expectedStatusCode int, actualStatusCode int) {
	if expectedStatusCode != actualStatusCode {
		t.Errorf("Expected Status: %v, Received: %v", expectedStatusCode, actualStatusCode)
	} else {
		log.Printf("Received Status Code: %v", actualStatusCode)

I’m able to add a product into my table, but getting status code 500.
Where I’m getting this wrong?

When you run go test for the file that contains this code, I assume you get a stack trace. What does it say? I would guess that something inside of sendRequest is panicking.