digitalmars.D - gofmt
- bearophile (5/5) Apr 23 2011 I think this is a module (a standard command) of the Go standard library...
- Adam D. Ruppe (19/20) Apr 23 2011 Oh my. Check this out:
- Matthew Ong (11/31) May 12 2011 Hi,
I think this is a module (a standard command) of the Go standard library, it formats Go code in a standard way: http://golang.org/cmd/gofmt/ People use it, it's a way to "enforce" a shared coding style in the community of programmers of a language. So they are able to share modules with each other better. Bye, bearophile
Apr 23 2011
http://golang.org/cmd/gofmt/Oh my. Check this out: Examples To check files for unnecessary parentheses: gofmt -r '(a) -> a' -l *.go To remove the parentheses: What a scary example. What an AST considers unnecessary parenthesis is probably very different from what I consider unnecessary. I like to use a lot of parenthesis. Sometimes I don't remember the precedence rules exactly, sometimes I like them as easy anchors in case I change the code, and sometimes they serve no purpose except visual grouping (often when combined with some whitespace). I think a program like this would make code less readable. Thankfully, the parens thing is just an example of a custom user rule*, but that it's the one they gave on the manual scares me that people actually would do that. Style has rules to follow, but it has exceptions too. Computers and humans are comfortable reading different things. * If there's custom rules, will the code still be formatted in a standard way?
Apr 23 2011
On 4/23/2011 10:37 PM, Adam D. Ruppe wrote:Hi, good idea. Something to help developer to find missing (){} or such way is import help and also layout of indentation. As for Java, Sun used to defined a common coding standard and also naming convention so that developer can easily navigate the huge API tree without much help. As for D, currently I am using grepWin to learn how D does it. -- Matthew Ong email: ongbp yahoo.comhttp://golang.org/cmd/gofmt/Oh my. Check this out: Examples To check files for unnecessary parentheses: gofmt -r '(a) -> a' -l *.go To remove the parentheses: What a scary example. What an AST considers unnecessary parenthesis is probably very different from what I consider unnecessary. I like to use a lot of parenthesis. Sometimes I don't remember the precedence rules exactly, sometimes I like them as easy anchors in case I change the code, and sometimes they serve no purpose except visual grouping (often when combined with some whitespace). I think a program like this would make code less readable. Thankfully, the parens thing is just an example of a custom user rule*, but that it's the one they gave on the manual scares me that people actually would do that. Style has rules to follow, but it has exceptions too. Computers and humans are comfortable reading different things. * If there's custom rules, will the code still be formatted in a standard way?
May 12 2011