func SetSudo(sudo string) func(client *Client) {
	return func(client *Client) {
		client.SetSudo(sudo)
	}
}
SetSudo is an option for NewClient to set sudo header
package gitea
import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"
	"sync"
	"github.com/hashicorp/go-version"
)
var jsonHeader = http.Header{"content-type": []string{"application/json"}}
func Version() string {
	return "0.14.0"
}
type Client struct {
	url            string
	accessToken    string
	username       string
	password       string
	otp            string
	sudo           string
	debug          bool
	client         *http.Client
	ctx            context.Context
	mutex          sync.RWMutex
	serverVersion  *version.Version
	getVersionOnce sync.Once
}
type Response struct {
	*http.Response
}
func NewClient(url string, options ...func(*Client)) (*Client, error) {
	client := &Client{
		url:    strings.TrimSuffix(url, "/"),
		client: &http.Client{},
		ctx:    context.Background(),
	}
	for _, opt := range options {
		opt(client)
	}
	if err := client.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil {
		return nil, err
	}
	return client, nil
}
func NewClientWithHTTP(url string, httpClient *http.Client) *Client {
	client, _ := NewClient(url, SetHTTPClient(httpClient))
	return client
}
func SetHTTPClient(httpClient *http.Client) func(client *Client) {
	return func(client *Client) {
		client.SetHTTPClient(httpClient)
	}
}
func (c *Client) SetHTTPClient(client *http.Client) {
	c.mutex.Lock()
	c.client = client
	c.mutex.Unlock()
}
func SetToken(token string) func(client *Client) {
	return func(client *Client) {
		client.mutex.Lock()
		client.accessToken = token
		client.mutex.Unlock()
	}
}
func SetBasicAuth(username, password string) func(client *Client) {
	return func(client *Client) {
		client.SetBasicAuth(username, password)
	}
}
func (c *Client) SetBasicAuth(username, password string) {
	c.mutex.Lock()
	c.username, c.password = username, password
	c.mutex.Unlock()
}
func SetOTP(otp string) func(client *Client) {
	return func(client *Client) {
		client.SetOTP(otp)
	}
}
func (c *Client) SetOTP(otp string) {
	c.mutex.Lock()
	c.otp = otp
	c.mutex.Unlock()
}
func SetContext(ctx context.Context) func(client *Client) {
	return func(client *Client) {
		client.SetContext(ctx)
	}
}
func (c *Client) SetContext(ctx context.Context) {
	c.mutex.Lock()
	c.ctx = ctx
	c.mutex.Unlock()
}