utils

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VERSION_HEADERS = map[string]string{
	"editor-version":       "Neovim/0.10.4",
	"ditor-plugin-version": "lazycopilot/v0.0.1",
	"User-Agent":           "lazycopilot/v0.0.1",
	"sec-fetch-site":       "none",
	"sec-fetch-mode":       "no-cors",
	"sec-fetch-dest":       "empty",
	"priority":             "u=4, i",
}

Functions

func GenerateMachineId

func GenerateMachineId() string

func GetConfigPath

func GetConfigPath() string

func GetDiff

func GetDiff(path string, staged bool) string

func GetFilePath

func GetFilePath(configDir, subDir, fileName string) string

func GetHttpClient

func GetHttpClient() *http.Client

func IsFileExists

func IsFileExists(path string) bool

func LoadFile

func LoadFile(p string) ([]byte, error)

func LoadFileJson

func LoadFileJson(p string, v interface{}) error

func Mkdir

func Mkdir(path string) error

func MustJsonBytes

func MustJsonBytes(data interface{}) []byte

func SaveAuthToken

func SaveAuthToken(filePath, token, username, clientId string) error

func SaveFile

func SaveFile(p string, data interface{}) error

func SetCurrentOSName

func SetCurrentOSName() string

func StageChanges

func StageChanges(path string) error

Types

type CachedToken

type CachedToken struct {
	User        string `json:"user"`
	OauthToken  string `json:"oauth_token"`
	GithubAppID string `json:"githubAppId"`
}

type GithubUser

type GithubUser struct {
	Login string `json:"login"`
	ID    int    `json:"id"`
}

func CheckCachedToken

func CheckCachedToken(filePath, clientId string) (*GithubUser, error)

func FetchGithubUserInfo

func FetchGithubUserInfo(token string) (*GithubUser, error)

type Headers

type Headers map[string]string

type HttpOptions

type HttpOptions struct {
	Url     string
	Method  string
	Headers *Headers
	Body    interface{}
}

type HttpResponse

type HttpResponse struct {
	*http.Response
}

func HttpRequest

func HttpRequest(ctx context.Context, opts HttpOptions) (*HttpResponse, error)

func (*HttpResponse) JsonDecode

func (r *HttpResponse) JsonDecode(v any) error

func (*HttpResponse) StringDecode

func (r *HttpResponse) StringDecode() (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL