1

I am working on a large go codebase and go code doesn't seem to be properly formatted.

I want to know if there is an option in go that will in some way assert me that what places I need to change the code styling. I am not using any IDE. go fmt does that job but I do not want the styling to be taken care of automatically. I could not find any option / parameter that I could pass to go fmt to do the same.

Is there any way I can either (sort of) dry run go fmt and spit out the formatting mistakes or use any other utility to do so?

user1079065
  • 2,085
  • 9
  • 30
  • 53

1 Answers1

3

The go fmt command runs the gofmt command. Use the gofmt command directly for more control.

# use -d flag to print difference between file at path and formatted file
gofmt -d path

# no flags prints the formatted file to stdout.  This is the dry run.
gofmt path
Charlie Tumahai
  • 113,709
  • 12
  • 249
  • 242