goimportfmt

package module
v0.0.0-...-9f09bec Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 14 Imported by: 0

README

goimportfmt

Like goimports, but removes blank lines

This library and command is alpha quality. It may have breaking changes in the future.

Install

$ go install github.com/morikuni/goimportfmt/cmd/goimportfmt

Usage

$ goimportfmt -w path/to/file.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectModulePath

func DetectModulePath(file string) (string, error)

func Process

func Process(src io.Reader, dst io.Writer, opts ...Option) error

Types

type Context

type Context struct {
	ModulePath string
}

type FormatFunc

type FormatFunc func(*Context, []*Import) GroupedImports

type GroupedImports

type GroupedImports map[int][]*Import

func (GroupedImports) Add

func (gp GroupedImports) Add(n int, i *Import)

func (GroupedImports) WriteTo

func (gp GroupedImports) WriteTo(w io.Writer) (written int64, _ error)

type Import

type Import struct {
	Name    string
	Path    string
	Docs    []string
	Comment string
}

type Option

type Option func(*config)

func WithFormatFunc

func WithFormatFunc(f FormatFunc) Option

func WithModulePath

func WithModulePath(path string) Option

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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