gofmtprintlinter

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 6 Imported by: 0

README

gofmtprintlinter

gofmtprintlinter is a static analysis tool to detect fmt.Print or fmt.Println or fmt.Printf.


package main

import "fmt"

func main() {
	fmt.Print("Hello, world!") // detect this

	fmt.Println("Hello, world!") // detect this

	fmt.Printf("Hello, world!") // detect this
}

You can add an ignore comment so that 'gofmtprintlinter' is not detected


package main

import "fmt"

func main() {
    //lint:ignore gofmtprintlinter ignore
	fmt.Print("Hello, world!") // don't detect this by ignore comment
}

Install

go install github.com/olibaa/gofmtprintlinter/cmd/gofmtprintlinter@latest

Usage

check for specific packages

gofmtprintlinter [Directory Path]

check all packages

gofmtprintlinter ./...

Ignore Generated File

Specify -ignore-gen-file and -generated-comment as options.

Ignore the generated file with the -ignore-gen-file option.

For the -generated-comment option, enter a comment that can be identified as a Generate File.

gofmtprintlinter -ignore-gen-file -generated-comment="Generated File Comment"  ./...

The default for the -generated-comment option is "Code generated by".

If the "-generated-comment" option is not specified, the default value will be used.

gofmtprintlinter -ignore-gen-file  ./...

License

License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: name,
	Doc:  doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		commentmap.Analyzer,
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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