You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: mode.go
    path of file: ./repos/hoverfly/hoverctl/wrapper
    
    the code of the file until where you have to start completion: package wrapper

import (
	"encoding/json"
	"errors"

	"github.com/SpectoLabs/hoverfly/core/handlers/v2"
	"github.com/SpectoLabs/hoverfly/hoverctl/configuration"
)

// GetMode will go the state endpoint in Hoverfly, parse the JSON response and return the mode of Hoverfly
func GetMode(target configuration.Target) (*v2.ModeView
    
func GetMode(target configuration.Target) (*v2.ModeView, error) {
	response, err := doRequest(target, "GET", v2ApiMode, "", nil)
	if err != nil {
		return nil, err
	}

	defer response.Body.Close()

	err = handleResponseError(response, "Could not retrieve mode")
	if err != nil {
		return nil, err
	}

	var modeView v2.ModeView

	err = UnmarshalToInterface(response, &modeView)
	if err != nil {
		return nil, err
	}

	return &modeView, nil
}