3.4. コードの簡素化
指定されたパス code_path でコードを簡素化するには、以下のように -s オプションを指定して gofmt オプションを実行します。
Red Hat Enterprise Linux 7 の場合:
scl enable go-toolset-1.11 'gofmt -s code_path'
$ scl enable go-toolset-1.11 'gofmt -s code_path'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Red Hat Enterprise Linux 8 の場合:
gofmt -s code_path
$ gofmt -s code_pathCopy to Clipboard Copied! Toggle word wrap Toggle overflow
code_path の下にあるコードは簡素化されます。-d オプションを使用して違いを表示し、-w オプションを使用してコードに変更を適用します。