Giter VIP home page Giter VIP logo

internal-linter-image's Introduction

Internal linter image

Overview

custom-gcl is a custom version of golangci-lint that includes custom linters.

Creating the Analyzer

Develope the main logic

  1. Create a Go file with the linter logic. For example, analyzer.go:
package custom-code-analysis-tools

import (
    "golang.org/x/tools/go/analysis"
)

var ExampleAnalyzer = &analysis.Analyzer{
        Name: "example",
        Doc:  "this is an example analyzer",
        Run:  run,
}

func run(pass *analysis.Pass) (interface{}, error) {
    for _, file := range pass.Files {
        // Implement your analysis logic here
        pass.Reportf(file.Pos(), "example warning")
    }
    return nil, nil
}

func New(conf any) ([]*analysis.Analyzer, error) {
    return []*analysis.Analyzer{ExampleAnalyzer}, nil
}
  1. Ensure your project utilizes a go.mod file for managing dependencies.

Generate the custom golagnci-lint binary

  1. Define your building configuration into .custom-gcl.yml.
version: v1.57.0
plugins:
  # a plugin from a Go proxy
  - module: 'github.com/golangci/plugin1'
    import: 'github.com/golangci/plugin1/foo'
    version: v1.0.0

  # a plugin from local source
  - module: 'github.com/golangci/plugin2'
    path: /my/local/path/plugin2
  1. From the root directory of your plugin project, run the command golangci-lint custom (or golangci-lint custom -v to have logs):
golangci-lint custom -v

Configuring Your Project for custom golangci-lint

To configure golangci-lint to use your custom linters, perform the following steps:

  1. Add or update the .golangci.yml file in the root directory of the project you want to lint:
linters-settings:
  custom:
    your_linter_name:
      type: "module"
      description: This is an example usage of a plugin linter.
      settings:
        message: hello
linters:
  disable-all: true
  enable:
      - your_linter_name

internal-linter-image's People

Contributors

ppsecuk avatar djenchik avatar anton-wallester avatar

Stargazers

Ezequiel Rodriguez avatar

Watchers

Vjatseslav Pokatsalov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.