goremovelines

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 11 Imported by: 1

README

goremovelines

Actions Status Coverage Status PkgGoDev go-report

Remove leading / trailing blank lines in Go functions, structs, if, switches, blocks.

Installation

go install github.com/Eun/goremovelines/cmd/goremovelines@latest

Usage

usage: goremovelines [<flags>] [<path>...]

Remove leading / trailing blank lines in Go functions, structs, if, switches, blocks.

Flags:
  -h, --help             Show context-sensitive help (also try --help-long and --help-man).
  -r, --remove=func|struct|if|switch|case|for|interface|block ...  
                         Remove blank lines for the context (specify it multiple times, e.g.: --remove=func --remove=struct)
  -w, --toSource         Write result to (source) file instead of stdout
  -s, --skip=DIR... ...  Skip directories with this name when expanding '...'.
      --vendor           Enable vendoring support (skips 'vendor' directories and sets GO15VENDOREXPERIMENT=1).
  -d, --debug            Display debug messages.
  -v, --version          Show application version.

Args:
  [<path>]  Directories to format. Defaults to ".". <path>/... will recurse.

It is possible to combine it with gofmt/goimport/goreturns using gomultifmt

package main

import "fmt"

func main() {

  fmt.Print("Hello")
  
  fmt.Print("World")

}

will be transformed to

package main

import "fmt"

func main() {
	fmt.Print("Hello")

	fmt.Print("World")
}

Build History

Build history

Documentation

Index

Constants

View Source
const (
	// FuncMode should be set to remove empty lines in functions.
	FuncMode = 1 << iota
	// StructMode should be set to remove empty lines in structs.
	StructMode = 1 << iota
	// IfMode should be set to remove empty lines in if blocks.
	IfMode = 1 << iota
	// SwitchMode should be set to remove empty lines in functions.
	SwitchMode = 1 << iota
	// CaseMode should be set to remove empty lines in case blocks.
	CaseMode = 1 << iota
	// ForMode should be set to remove empty lines in for blocks.
	ForMode = 1 << iota
	// InterfaceMode should be set to remove empty lines in interface blocks.
	InterfaceMode = 1 << iota
	// BlockMode should be set to remove empty lines in blocks.
	BlockMode = 1 << iota
	// AllMode includes all modes.
	AllMode = FuncMode | StructMode | IfMode | SwitchMode | CaseMode | ForMode | InterfaceMode | BlockMode
)

Variables

View Source
var Debug = false

Debug enables/disables debug output.

Functions

func CleanFile

func CleanFile(src string, out io.Writer, mode Mode) error

CleanFile cleans a source code with the specific mode, it writes the cleaned output to `out`.

func CleanFilePath

func CleanFilePath(path string, out io.Writer, mode Mode) error

CleanFilePath cleans a file with the specific mode, it writes the cleaned output to `out`.

Types

type Mode

type Mode int

Mode is a bitmask that defines which lines should be removed.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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