github.com/stripe/stripe-go/v76@v76.25.0/scripts/gofmt.sh (about)

     1  #!/bin/bash
     2  
     3  find_files() {
     4    find . -name '*.go' -not -path "./vendor/*" -not -path "./.git/*"
     5  }
     6  
     7  bad_files=$(find_files | xargs gofmt -s -l)
     8  
     9  if [[ "$1" == "check" ]]; then
    10      if [[ -n "${bad_files}" ]]; then
    11          echo "!!! gofmt -s needs to be run on the following files: "
    12          echo "${bad_files}"
    13          exit 1
    14      fi
    15  fi
    16  
    17  for file in ${bad_files}; do
    18      gofmt -s -w "${file}"
    19  done
    20  exit 0