Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.
/ go-nonewlines Public archive

👮 Removes newlines from the beginning and end of functions

Notifications You must be signed in to change notification settings

andrewkroh/go-nonewlines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NOTE: This is no longer maintained and gofumpt can be used to enforce this rule.

go-nonewlines

Build Status Go Documentation

go-nonewlines provides a nonewlines command that formats your Go code to remove newlines that occur at the beginning and end of a function. It's not a thoroughly tested tools so use with caution.

  • Trim newlines between opening brace and first statement (except for multiline function declarations).
  • Trim newlines before the closing brace.

Installation and Usage

Package documentation can be found on GoDoc.

Installation can be done with a normal go get.

$ go get github.com/andrewkroh/go-nonewlines/cmd/nonewlines

The arguments are similar to that of goimports. To view a diff without actually updating any files use:

nonewlines -d .

To update files use

nonewlines -l -w .

Example

$ nonewlines -d -l $(find . -name '*.go' | grep -v vendor)
./testify/assert/assertions.go
diff -u ./testify/assert/assertions.go.orig ./testify/assert/assertions.go
--- ./testify/assert/assertions.go.orig 2017-10-16 00:19:59.000000000 +0200
+++ ./testify/assert/assertions.go  2017-10-16 00:19:59.000000000 +0200
@@ -34,13 +34,11 @@
 //
 // This function does no assertion of any kind.
 func ObjectsAreEqual(expected, actual interface{}) bool {
-
    if expected == nil || actual == nil {
        return expected == actual
    }
 
    return reflect.DeepEqual(expected, actual)
-
 }

About

👮 Removes newlines from the beginning and end of functions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages