github.com/Psiphon-Labs/tls-tris@v0.0.0-20230824155421-58bf6d336a9a/_dev/utils/fmtcheck.sh (about)

     1  #!/bin/sh
     2  # Copyright 2012 The Go Authors. All rights reserved.
     3  # Use of this source code is governed by a BSD-style
     4  # license that can be found in the LICENSE file.
     5  
     6  gofiles=$(find . -iname "*.go" ! -path "*/_dev/*")
     7  #[ -z "$gofiles" ] && exit 0
     8  
     9  unformatted=$(gofmt -l $gofiles)
    10  [ -z "$unformatted" ] && exit 0
    11  
    12  # Some files are not gofmt'd. Print message and fail.
    13  
    14  echo >&2 "Go files must be formatted with gofmt. Please run:"
    15  for fn in $unformatted; do
    16  	echo >&2 "  gofmt -w $PWD/$fn"
    17  done
    18  
    19  exit 1
    20