3.4. コードの簡素化

指定されたパス code_path でコードを簡素化するには、以下のように -s オプションを指定して gofmt オプションを実行します。

  • Red Hat Enterprise Linux 7 の場合:

    $ scl enable go-toolset-1.11 'gofmt -s code_path'
  • Red Hat Enterprise Linux 8 の場合:

    $ gofmt -s code_path

code_path の下にあるコードは簡素化されます。-d オプションを使用して違いを表示し、-w オプションを使用してコードに変更を適用します。