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: recaptcha.go
    path of file: ./repos/Cloudreve/pkg/recaptcha
    
    the code of the file until where you have to start completion: package recaptcha

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"time"
)

const reCAPTCHALink = "https://www.recaptcha.net/recaptcha/api/siteverify"

// VERSION the recaptcha api version
type VERSION int8

const (
	// V2 recaptcha api v2
	V2 VERSION = iota
	// V3 recaptcha api v3, more details can be found here : https://developers.google.com/recaptcha/docs/v3
	V3
	// DefaultTreshold Default minimin score when using V3 api
	DefaultTreshold float32 = 0.5
)

type reCHAPTCHARequest struct {
	Secret   string `json:"secret"`
	Response string `json:"response"`
	RemoteIP string `json:"remoteip,omitempty"`
}

type reCHAPTCHAResponse struct {
	Success        bool      `json:"success"`
	ChallengeTS    time.Time `json:"challenge
    
func (r *ReCAPTCHA) confirm(recaptcha reCHAPTCHARequest, options VerifyOption) (Err error) {
	Err = nil
	var formValues url.Values
	if recaptcha.RemoteIP != "" {
		formValues = url.Values{"secret": {recaptcha.Secret}, "remoteip": {recaptcha.RemoteIP}, "response": {recaptcha.Response}}
	} else {
		formValues = url.Values{"secret": {recaptcha.Secret}, "response": {recaptcha.Response}}
	}
	response, err := r.client.PostForm(r.ReCAPTCHALink, formValues)
	if err != nil {
		Err = fmt.Errorf("error posting to recaptcha endpoint: '%s'", err)
		return
	}
	defer response.Body.Close()
	resultBody, err := ioutil.ReadAll(response.Body)
	if err != nil {
		Err = fmt.Errorf("couldn't read response body: '%s'", err)
		return
	}
	var result reCHAPTCHAResponse
	err = json.Unmarshal(resultBody, &result)
	if err != nil {
		Err = fmt.Errorf("invalid response body json: '%s'", err)
		return
	}

	if options.Hostname != "" && options.Hostname != result.Hostname {
		Err = fmt.Errorf("invalid response hostname '%s', while expecting '%s'", result.Hostname, options.Hostname)
		return
	}

	if options.ApkPackageName != "" && options.ApkPackageName != result.ApkPackageName {
		Err = fmt.Errorf("invalid response ApkPackageName '%s', while expecting '%s'", result.ApkPackageName, options.ApkPackageName)
		return
	}

	if options.ResponseTime != 0 {
		duration := r.horloge.Since(result.ChallengeTS)
		if options.ResponseTime < duration {
			Err = fmt.Errorf("time spent in resolving challenge '%fs', while expecting maximum '%fs'", duration.Seconds(), options.ResponseTime.Seconds())
			return
		}
	}
	if r.Version == V3 {
		if options.Action != "" && options.Action != result.Action {
			Err = fmt.Errorf("invalid response action '%s', while expecting '%s'", result.Action, options.Action)
			return
		}
		if options.Threshold != 0 && options.Threshold >= result.Score {
			Err = fmt.Errorf("received score '%f', while expecting minimum '%f'", result.Score, options.Threshold)
			return
		}
		if options.Threshold == 0 && DefaultTreshold >= result.Score {
			Err = fmt.Errorf("received score '%f', while expecting minimum '%f'", result.Score, DefaultTreshold)
			return
		}
	}
	if result.ErrorCodes != nil {
		Err = fmt.Errorf("remote error codes: %v", result.ErrorCodes)
		return
	}
	if !result.Success && recaptcha.RemoteIP != "" {
		Err = fmt.Errorf("invalid challenge solution or remote IP")
	} else if !result.Success {
		Err = fmt.Errorf("invalid challenge solution")
	}
	return
}