Go language foundation go FMT command use example explanation

Time:2021-12-31

Go language foundation go FMT command use example explanation

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!

Recommended Today

Use vite to build vue3.0+ts+element plus+sass project

Installing the vite environment yarn create @vitejs/app Initialize vue+ts items with vite yarn create @vitejs/app project-name Project name, enter Select ‘Vue’ and enter Select ‘Vue ts’ enter complete Follow the steps to follow the prompts in the above figure cd project-name yarn yarn dev Run successfully Configure host vite.config.tsConfigure host and alias import { defineConfig […]