Documentation
¶
Overview ¶
utils/http_client.go
utils/path.go
Index ¶
- func CheckAndNotifyEnv(key, defaultValue string, logger *zap.Logger) (string, bool)
- func CheckEnvVariables(logger *zap.Logger)
- func CheckProviderEnvVariables(logger *zap.Logger)
- func DetectFileType(filePath string) string
- func ExpandPath(path string) (string, error)
- func FormatDirectoryContent(files []FileInfo, maxTotalSize int64) string
- func GenerateUUID() string
- func GetEnvOrDefault(key, defaultValue string) string
- func GetEnvVariables() string
- func GetFileBlame(filepath string) (string, error)
- func GetFileDiff(filepath string) (string, error)
- func GetFileHistory(filepath string) (string, error)
- func GetGitInfo() (string, error)
- func GetHomeDir() (string, error)
- func GetShellConfigFilePath(shellName string) string
- func GetShellHistory() (string, error)
- func GetShellHistoryFile() (string, error)
- func GetTerminalSize() (width int, height int, err error)
- func GetUserShell() string
- func InitializeLogger() (*zap.Logger, error)
- func IsTemporaryError(err error) bool
- func LogStartupInfo(logger *zap.Logger)
- func NewHTTPClient(logger *zap.Logger, timeout time.Duration) *http.Client
- func NewJSONReader(data []byte) io.Reader
- func ReadFileContent(filePath string, maxSize int64) (string, error)
- func ShouldSkipDir(dirName string) bool
- type APIClient
- type DirectoryScanOptions
- type FileInfo
- type LoggingTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAndNotifyEnv ¶
CheckAndNotifyEnv verifica se uma variável de ambiente está definida, registra se o padrão foi usado e retorna o valor
func CheckEnvVariables ¶
CheckEnvVariables verifica as variáveis de ambiente necessárias e informa o usuário
func CheckProviderEnvVariables ¶
CheckProviderEnvVariables verifica e notifica sobre as variáveis de ambiente específicas dos provedores
func DetectFileType ¶
DetectFileType detecta o tipo de arquivo com base na extensão
func ExpandPath ¶
ExpandPath expande o caractere ~ no início de um caminho para o diretório home do usuário. Se o caminho não começar com ~, ele é retornado sem modificações. A função não suporta a expansão de ~username, retornando um erro nesse caso.
func FormatDirectoryContent ¶
FormatDirectoryContent formata o conteúdo de vários arquivos em uma única string organizada com separadores claros e formatação adequada para cada tipo de arquivo.
func GenerateUUID ¶
func GenerateUUID() string
GenerateUUID gera um UUID (Universally Unique Identifier)
func GetEnvOrDefault ¶
GetEnvOrDefault retorna o valor da variável de ambiente ou um valor padrão se não estiver definida
func GetEnvVariables ¶
func GetEnvVariables() string
GetEnvVariables retorna todas as variáveis de ambiente como uma string formatada.
func GetFileBlame ¶
Função auxiliar para obter blame de um arquivo
func GetFileDiff ¶
Função auxiliar para obter diferenças específicas de um arquivo
func GetFileHistory ¶
Função auxiliar para obter o histórico de um arquivo específico
func GetGitInfo ¶
GetGitInfo retorna informações detalhadas sobre o repositório Git atual
func GetHomeDir ¶
GetHomeDir retorna o diretório home do usuário atual.
func GetShellConfigFilePath ¶
GetShellConfigFilePath retorna o caminho do arquivo de configuração do shell com base no nome do shell.
func GetShellHistory ¶
GetShellHistory lê o arquivo de histórico do shell e retorna seu conteúdo como string.
func GetShellHistoryFile ¶
GetShellHistoryFile retorna o caminho do arquivo de histórico do shell com base no shell do usuário.
func GetTerminalSize ¶
GetTerminalSize retorna a largura e a altura do terminal.
func GetUserShell ¶
func GetUserShell() string
GetUserShell retorna o shell do usuário atual com base na variável de ambiente SHELL.
func InitializeLogger ¶
InitializeLogger configura e inicializa um logger com base nas variáveis de ambiente.
func IsTemporaryError ¶
IsTemporaryError verifica se o erro é temporário e pode ser retryado. Desde o Go 1.18, 'Temporary' é desaconselhado. Normalmente só timeout é considerado seguro para retry.
func LogStartupInfo ¶ added in v1.10.1
func NewHTTPClient ¶
NewHTTPClient cria um cliente HTTP com LoggingTransport e timeout configurado
func NewJSONReader ¶
NewJSONReader cria um io.Reader a partir de um []byte para enviar em requisições HTTP
func ReadFileContent ¶
ReadFileContent lê o conteúdo de um arquivo, expandindo ~ para o diretório home, mostrando um indicador de progresso para arquivos grandes.
func ShouldSkipDir ¶
ShouldSkipDir verifica se um diretório deve ser ignorado
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient é um cliente HTTP especializado para APIs REST
func NewAPIClient ¶
NewAPIClient cria um novo cliente API com cabeçalhos padrão
type DirectoryScanOptions ¶
type DirectoryScanOptions struct {
MaxTotalSize int64 // Tamanho máximo do conteúdo total (em bytes)
MaxFilesToProcess int // Número máximo de arquivos a processar
Logger *zap.Logger
Extensions []string // Extensões de arquivo a incluir (vazio = todas)
ExcludeDirs []string // Diretórios a excluir
ExcludePatterns []string // Padrões de nome de arquivo a excluir (ex: "*.tmp")
IncludeHidden bool // Incluir arquivos/diretórios ocultos?
OnFileProcessed func(info FileInfo) // Callback para cada arquivo processado
}
DirectoryScanOptions configura opções para escaneamento de diretórios
func DefaultDirectoryScanOptions ¶
func DefaultDirectoryScanOptions(logger *zap.Logger) DirectoryScanOptions
DefaultDirectoryScanOptions retorna opções padrão para escaneamento
type FileInfo ¶
FileInfo armazena informações e conteúdo de um arquivo
func ProcessDirectory ¶
func ProcessDirectory(dirPath string, options DirectoryScanOptions) ([]FileInfo, error)
ProcessDirectory processa um diretório recursivamente, coletando conteúdo de arquivos que correspondam aos critérios definidos nas opções.
type LoggingTransport ¶
type LoggingTransport struct {
Logger *zap.Logger
Transport http.RoundTripper
MaxBodySize int
}
LoggingTransport é um http.RoundTripper que adiciona logs às requisições e respostas