github.com/IBM-Blockchain/fabric-operator@v1.0.4/scripts/checks.sh (about) 1 #!/bin/bash 2 # 3 # Copyright contributors to the Hyperledger Fabric Operator project 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 # Licensed under the Apache License, Version 2.0 (the "License"); 8 # you may not use this file except in compliance with the License. 9 # You may obtain a copy of the License at: 10 # 11 # http://www.apache.org/licenses/LICENSE-2.0 12 # 13 # Unless required by applicable law or agreed to in writing, software 14 # distributed under the License is distributed on an "AS IS" BASIS, 15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 # See the License for the specific language governing permissions and 17 # limitations under the License. 18 # 19 20 # Need to run this before go vet 21 go mod download 22 23 echo "Running 'go vet'" 24 OUTPUT=`go vet -all ./... 2>&1` 25 if [ -n "$OUTPUT" ]; then 26 echo "The following files contain go vet errors" 27 echo $OUTPUT 28 exit 1 29 fi 30 echo "No 'go vet' issues found" 31 32 cd /tmp 33 go install golang.org/x/tools/cmd/goimports@ff88973b1e4e 34 cd - 35 echo "Checking imports ..." 36 found=`goimports -l \`find . -path ./vendor -prune -o -name "*.go" -print\` 2>&1` 37 found=$(echo "$found" | grep -v generated) 38 if [ "$found" != "" ]; then 39 echo "The following files have import problems:" 40 echo "$found" 41 echo "You may run 'goimports -w <file>' to fix each file." 42 exit 1 43 fi 44 echo "All files are properly formatted"