Gofmt Beautifier
About
Gofmt beautifier for Unibeautify
Package | Docs | Latest |
---|---|---|
@unibeautify/beautifier-gofmt | v0.1.0 | |
unibeautify | v0.17.1 |
Prerequisites
Please install the following prerequisites.
Gofmt executable
Gofmt executable should not be confused with Gofmt beautifier with the same name. Executables are non-Node.js tools for code formatting while beautifiers are Node.js packages which wrap an executable to be used by Unibeautify.
Gofmt executable is a third-party program you must install manually and is required for beautification.
See https://golang.org/cmd/gofmt/ for more information.
Install Gofmt (gofmt
) by following https://golang.org/doc/install.
If you have questions or want to report a bug, go to https://github.com/golang/go/issues.
Install
Install with npm
:
npm install --save-dev unibeautify @unibeautify/beautifier-gofmt
Or with yarn
:
yarn add --dev unibeautify @unibeautify/beautifier-gofmt
Usage
Add Gofmt
to beautifiers
language option.
A .unibeautifyrc.json
file would look like the following:
{
"Go": {
"beautifiers": [
"Gofmt"
]
}
}
Advanced
Example advanced configuration:
{
"Go": {
"beautifiers": [
"Gofmt"
],
"Gofmt": {
"Gofmt": {
"path": "/absolute/path/to/gofmt"
}
}
}
}
Options
No configuration options are supported. The following languages are supported without options: Go.
FAQ
How to use Gofmt in Atom, VSCode, and other editors?
See the editor integration documentation for installation instructions for your editor of choice.
How to enable Gofmt to format on save?
See the editor integration documentation for format on save instructions for your editor of choice.
How to run Gofmt on all files?
You can run Gofmt on all of your files for every commit with Unibeautify CI.
Is there a Gofmt sandbox or playground?
You can quickly try Gofmt online with Unibeautify Playground.
Troubleshooting
Below are instructions for each of the supported Operating Systems.
Windows
Open the Command Prompt.
Show me how to open the Command Prompt.
Find the path to Gofmt by running the command:
where gofmt
Which will return an absolute path like one of the following:
C:\absolute\path\to\gofmt
C:\absolute\path\to\gofmt.exe
C:\absolute\path\to\gofmt.bat
If where
fails to return an executable path then you need to fix your PATH
Environment Variable.
Show me how to change my
PATH
environment variable.
If you know the executable path go to the Configure section and replace /absolute/path/to/gofmt
with your specific executable path value.
macOS
Open the Terminal application.
Show me how to open the Terminal.
Find the path to Gofmt by running the command:
which gofmt
Which will return an absolute path like one of the following:
/absolute/path/to/gofmt
/absolute/path/to/gofmt.sh
/absolute/path/to/gofmt.bash
If which
fails to return an executable path then you need to fix your PATH
Environment Variable:
Show me how to change my
PATH
environment variable.
If you know the executable path go to the Configure section and replace /absolute/path/to/gofmt
with your specific executable path value.
Linux
Open the Terminal application.
Show me how to open the Terminal.
Find the path to Gofmt by running the command:
which gofmt
Which will return an absolute path like one of the following:
/absolute/path/to/gofmt
/absolute/path/to/gofmt.sh
/absolute/path/to/gofmt.bash
If which
fails to return an executable path then you need to fix your PATH
Environment Variable.
Show me how to change my
PATH
environment variable.
If you know the executable path go to the Configure section replace /absolute/path/to/gofmt
with your specific executable path value.