pkgalias

package module
v0.0.0-...-4c440d2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: MIT Imports: 10 Imported by: 0

README

pkgalias

A linter for Go to fix alias of package.

Install

$ go install github.com/sachaos/pkgalias

Quickstart

1. Prepare config .pkgalias.yaml

settings:
- alias: validatorv10
  fullpath: github.com/go-playground/validator/v10

2. Example source code

package main

import "github.com/go-playground/validator/v10"

type User struct {
	Name string `validate:"required"`
}

func main() {
	user := &User{
		Name: "sachaos",
	}

	validate := validator.New()
	if err := validate.Struct(user); err != nil {
		panic(err)
	}
}

3. Run pkgalias

$ pkgalias ./
./main.go:3:8: invalid alias: package name should be "validatorv10", insert this.
./main.go:14:14: invalid alias: use "validatorv10" instead of "validator"

4. Fix automatically with -fix option

$ pkgalias -fix ./
./main.go:3:8: invalid alias: package name should be "validatorv10", insert this.
./main.go:14:14: invalid alias: use "validatorv10" instead of "validator"
package main

import validatorv10 "github.com/go-playground/validator/v10"

type User struct {
	Name string `validate:"required"`
}

func main() {
	user := &User{
		Name: "sachaos",
	}

	validate := validatorv10.New()
	if err := validate.Struct(user); err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "pkgalias",
	Doc:  doc,
	Run:  runWithConfig(loadConfig()),
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
	},
}

Analyzer is ...

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