Coder Social home page Coder Social logo

Comments (9)

mvdan avatar mvdan commented on May 27, 2024

Good idea :) I wonder if the former would be useful in any specific case; I can't think of one right now. Perhaps when commenting out code?

foo()
//bar()
baz()

I'll check with a few large repositories of Go code and get an idea.

from gofumpt.

dnwe avatar dnwe commented on May 27, 2024

tbh even that I would consider a useful feature because when I review the git diff output it would highlight wherever I have accidentally left some commented out code that should be deleted :)

from gofumpt.

mvdan avatar mvdan commented on May 27, 2024

Note to self - be careful with line directives, such as //go:generate, //+build, and //line. If people use custom directives that we don't know about, this could end badly.

from gofumpt.

mvdan avatar mvdan commented on May 27, 2024

Oh, the files containing //+build are buggy, actually. That should be // +build.

from gofumpt.

mvdan avatar mvdan commented on May 27, 2024

Done; any feedback welcome.

from gofumpt.

dnwe avatar dnwe commented on May 27, 2024

😘👌🏻 has worked well on the repos I've tested so far. Thank you!

Having also tried it across a number of OSS repos, one minor tweak might be to consider // followed by one or more additional non-alphanumerical characters (e.g., /, *, +, -) as likely to be block comments of a particular "style" intended to separate sections of code or for a Copyright header or something

e.g.,
https://github.com/Shopify/sarama/blob/5d2af84cf5e2dd36f2daecaaafa13c4e286f20fd/mocks/consumer.go#L37-L46

from gofumpt.

mvdan avatar mvdan commented on May 27, 2024

Thanks; that's a good idea. I'll update the rule to be a bit more conservative.

from gofumpt.

sylr avatar sylr commented on May 27, 2024

I make a great distinction between:

A comment:

// This is a comment
if thisiscommentedcode == false {

}

And commented code:

//// This is a comment
//if thisiscommentedcode == false {
//
//}

from gofumpt.

mvdan avatar mvdan commented on May 27, 2024

@sylr are you bringing this up because gofumpt isn't doing what you think it should? If so, please raise a new issue.

from gofumpt.

Related Issues (20)

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.