Git Product home page Git Product logo

go-nonewlines's Introduction

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)
-
 }

go-nonewlines's People

Contributors

andrewkroh avatar

Stargazers

 avatar

Watchers

 avatar  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.