Go fmt on a whole source tree

前端 未结 6 989
借酒劲吻你
借酒劲吻你 2021-01-30 03:36

I have a project currently organized something like this:

~/code/go
         /bin
         /pkg
         /src
             /proj/main.go
                  /some_packa         


        
6条回答
  •  佛祖请我去吃肉
    2021-01-30 04:40

    If you use gofmt instead of go fmt, it's recursive. For example, following command

    gofmt -s -w .
    

    (notice the little dot at end) recursively formats, simplifies, and saves result into every file under current directory. I have a shell alias gf defined as gofmt -s -w . and find it quite handy.

    Try gofmt -l . (list files whose formatting differs from gofmt's) first if you want :-)

提交回复
热议问题