Documentation
¶
Index ¶
- Constants
- func IsFileExist(workdir, filename string) bool
- func NewDirWalker() repository.DirWalker
- func NewFileWalker() repository.FileWalker
- func NewGitHubDirWalker(ctx context.Context, client *GitHubClient, owner, repo string) repository.DirWalker
- func Run(workdir, cmd string, args ...string) (string, string, int, error)
- type DirWalker
- type FileWalker
- type GitHubClient
- func (c *GitHubClient) GetContent(ctx context.Context, owner, repo, path string) (string, error)
- func (c *GitHubClient) SearchCode(ctx context.Context, query string, opt *repository.SearchCodeOption) (repository.SearchCodeResult, error)
- func (c *GitHubClient) WalkContents(ctx context.Context, owner, repo, startPath string, fn WalkContentsFunc) error
- type GitHubDirWalker
- type HttpClient
- type WalkContentsFunc
Constants ¶
const ItemTypeDir = "dir"
Variables ¶
This section is empty.
Functions ¶
func IsFileExist ¶
func NewDirWalker ¶
func NewDirWalker() repository.DirWalker
func NewFileWalker ¶
func NewFileWalker() repository.FileWalker
func NewGitHubDirWalker ¶
func NewGitHubDirWalker( ctx context.Context, client *GitHubClient, owner, repo string, ) repository.DirWalker
NewGitHubDirWalker creates a new GitHubDirWalker instance
Types ¶
type DirWalker ¶
type DirWalker struct{}
func (*DirWalker) Walk ¶
func (dw *DirWalker) Walk( _ context.Context, function repository.WalkDirFunc, prefixFunc repository.WalkDirNextPrefixFunc, prefix, path string, ignoreDot bool, maxDepth int, ) error
type FileWalker ¶
type FileWalker struct{}
func (*FileWalker) Walk ¶
func (fw *FileWalker) Walk( ctx context.Context, function repository.WalkFileFunc, path, extension string, ignoreDot bool, ) error
type GitHubClient ¶
func NewGitHubClient ¶
func NewGitHubClient() (*GitHubClient, error)
func (*GitHubClient) GetContent ¶
GetContent retrieves the content of a file or directory in a GitHub repository using the GitHub API. If path points to a file, it returns the file content. If path points to a directory, it returns a formatted directory listing.
func (*GitHubClient) SearchCode ¶
func (c *GitHubClient) SearchCode( ctx context.Context, query string, opt *repository.SearchCodeOption, ) (repository.SearchCodeResult, error)
SearchCode searches for code in a GitHub repository using the GitHub API. https://github.com/google/go-github/blob/b98b707876c8b20b0e1dbbdffb7898a5fcc2169d/github/search.go#L62 GitHub API docs: https://docs.github.com/rest/search/search#search-code
func (*GitHubClient) WalkContents ¶
func (c *GitHubClient) WalkContents( ctx context.Context, owner, repo, startPath string, fn WalkContentsFunc, ) error
WalkContents walks the directory tree of a GitHub repository. It calls the provided WalkContentsFunc for each file or directory in the tree. The function is called first with the start path, and then with each file or directory found. If the start path is a file, the function is called only for that file. If the start path is a directory, the function is called for that directory and all files and directories in it.
type GitHubDirWalker ¶
type GitHubDirWalker struct {
// contains filtered or unexported fields
}
GitHubDirWalker implements the repository.DirWalker interface for GitHub repositories
func (*GitHubDirWalker) Walk ¶
func (w *GitHubDirWalker) Walk( ctx context.Context, function repository.WalkDirFunc, prefixFunc repository.WalkDirNextPrefixFunc, prefix, path string, ignoreDot bool, maxDepth int, ) error
Walk implements the repository.DirWalker interface for GitHub repositories
type HttpClient ¶
type HttpClient struct{}
func NewHttpClient ¶
func NewHttpClient() *HttpClient
func (*HttpClient) HttpGet ¶
func (c *HttpClient) HttpGet(url string) (io.ReadCloser, error)
type WalkContentsFunc ¶
WalkContentsFunc is the function called for each file or directory visited by WalkContents. The path argument contains the path to the file or directory. The isDir argument is true if the path is a directory and false if it is a file. The depth argument indicates how deep in the tree the current item is. If the function returns an error, walking is stopped.