Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFencedCB ¶
AddFencedCB addresses MD040 issues found with markdownlint by adding the input language to fenced code blocks in the input filePath.
Parameters:
filePath: A string representing the path to the markdown file to modify. language: A string representing the language to be added to the fenced code block.
Returns:
error: An error if the markdown file fails to be modified.
Example:
err := AddFencedCB("/path/to/markdown/file", "go")
if err != nil {
log.Fatalf("Error modifying markdown file: %v", err)
}
func ClearPCCache ¶
func ClearPCCache() error
ClearPCCache clears the pre-commit cache.
Returns:
error: An error if the cache fails to clear.
Example:
err := ClearPCCache()
if err != nil {
log.Fatalf("Error clearing cache: %v", err)
}
func InstallGoPCDeps ¶
func InstallGoPCDeps() error
InstallGoPCDeps installs dependencies used for pre-commit with Golang projects.
Returns:
error: An error if the dependencies fail to install.
Example:
err := InstallGoPCDeps()
if err != nil {
log.Fatalf("Error installing dependencies: %v", err)
}
func InstallPCHooks ¶
func InstallPCHooks() error
InstallPCHooks installs pre-commit hooks locally.
Returns:
error: An error if the hooks fail to install.
Example:
err := InstallPCHooks()
if err != nil {
log.Fatalf("Error installing hooks: %v", err)
}
func RunPCHooks ¶
func RunPCHooks() (context.CancelFunc, chan error)
RunPCHooks runs all pre-commit hooks locally. The function runs the hooks in a goroutine and returns immediately. To check if the hooks have completed and if they have succeeded, callers must read from the returned error channel.
Returns:
context.CancelFunc: A function that can be called to cancel the execution of the hooks. This is useful if the caller decides it doesn't need the hooks to complete (for instance, if the program is about to exit).
chan error: A channel that will receive one value: the error from running the hooks, or nil if the hooks ran successfully. The channel is buffered and will never block. It will always receive a value, so callers should always read from it, even if they call the cancel function.
Example:
cancel, errCh := RunPCHooks()
// In some other part of the program: err := <-errCh
if err != nil {
log.Fatalf("Error running hooks: %v", err)
}
// If the program doesn't care about the hooks anymore, it can cancel them: cancel()
func UpdatePCHooks ¶
func UpdatePCHooks() error
UpdatePCHooks updates pre-commit hooks locally.
Returns:
error: An error if the hooks fail to update.
Example:
err := UpdatePCHooks()
if err != nil {
log.Fatalf("Error updating hooks: %v", err)
}
Types ¶
This section is empty.