zaplint

package module
v0.0.0-...-d810ce0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

README

zaplint

GitHub Actions Workflow Status Codecov GitHub License

zaplint is a Go static analysis tool that ensures consistent code style when using the zap logging library.

Features

  • Enforce capitalized log messages.
  • Enforce replacing zap.Any with the appropriate type.
  • Enforce a single key naming convention: snake_case, kebab-case, camelCase, or PascalCase.
  • Exclude specified files or patterns from analysis.

Installation

To install zaplint, use the following command:

go install github.com/rleungx/zaplint/cmd/zaplint@latest

Usage

You can run zaplint through the following command:

zaplint -key-naming-convention kebab -capitalized-message true -replace-any true ./...

Configuration

You can configure zaplint using the following flags:

  • -capitalized-message: Enforce capitalized log messages.
  • -replace-any: Enforce replacing zap.Any with the appropriate type.
  • -key-naming-convention: Enforce a single key naming convention (snake|kebab|camel|pascal).
  • -exclude-files: Exclude files matching the given patterns (comma-separated).

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	SnakeCase  = "snake"
	KebabCase  = "kebab"
	CamelCase  = "camel"
	PascalCase = "pascal"
)

Variables

This section is empty.

Functions

func New

func New(opts *Options) *analysis.Analyzer

New creates a new zaplint analyzer.

Types

type Options

type Options struct {
	CapitalizedMessage  bool     // Enforce capitalized message.
	ReplaceAny          bool     // Enforce replacing zap.Any with the appropriate type.
	KeyNamingConvention string   // Enforce a single key naming convention ("snake", "kebab", "camel", or "pascal").
	ExcludeFiles        []string // Exclude files matching the given patterns.
}

Options are options for the zaplint analyzer.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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