lint

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 13 Imported by: 0

README

goutils/v2/lint

The lint package is a part of goutils library. It provides utility functions for lint operations in Go.


Functions

InstallGoPCDeps
func InstallGoPCDeps() error

Install dependencies used for pre-commit with Golang projects.

InstallPCHooks
func InstallPCHooks() error

Installs pre-commit hooks locally.

UpdatePCHooks
func UpdatePCHooks() error

Update pre-commit hooks locally.

ClearPCCache
func ClearPCCache() error

Clears the pre-commit cache.

RunPCHooks
func RunPCHooks() error

Run all pre-commit hooks locally.

AddFencedCB
func AddFencedCB(filePath string, language string) error

Addresses MD040 issues found with markdownlint by adding the input language to fenced code blocks in the input filePath.


Installation

To use the goutils/v2/lint package, you need to install it via go get:

go get github.com/l50/goutils/v2/lint

Usage

After installation, you can import it in your project:

import "github.com/l50/goutils/v2/lint"

Tests

To run the tests for the goutils/v2/lint package, navigate to your $GOPATH/src/github.com/l50/goutils/v2/lint directory and run go test:

go test -v

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.


License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFencedCB

func AddFencedCB(filePath string, language string) error

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.

Jump to

Keyboard shortcuts

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