github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/scripts/gofmtcheck.sh (about)

     1  #!/usr/bin/env bash
     2  # Copyright (c) HashiCorp, Inc.
     3  # SPDX-License-Identifier: MPL-2.0
     4  
     5  
     6  # Check go fmt
     7  echo "==> Checking that code complies with go fmt requirements..."
     8  gofmt_files=$(go fmt ./...)
     9  if [[ -n ${gofmt_files} ]]; then
    10      echo 'gofmt needs running on the following files:'
    11      echo "${gofmt_files}"
    12      echo "You can use the command: \`go fmt\` to reformat code."
    13      exit 1
    14  fi
    15  
    16  exit 0