go fmt
The command is mainly used to help you format the written code file [many third-party integration software use the go FMT command]
1、 Use:
Go FMT < filename > go
Use the go FMT command, and more often use gofmt, which requires parameters
-w. Otherwise, the formatting result will not be written to the file. Gofmt – W SRC, you can format the entire project.
2、 Parameter introduction
-L displays the files that need to be formatted
-W writes the rewritten content directly to the file instead of printing the result to standard output.
-R add rewrite rules like “a [B: len (a)] – > a [B:]” to facilitate batch replacement
-S simplify the code in the file
-D displays the diff before and after formatting instead of writing to the file. The default is false
-E print all syntax errors to standard output. If this flag is not used, only the first 10 errors in different rows will be printed.
-Cpuprofile supports debugging mode and writes the corresponding cpufile to the specified file scope
The above is the details of the use example of go FMT command on the basis of go language. For more information on the basic commands of go language, please pay attention to other relevant articles of developeppaper!