github.com/wulonghui/docker@v1.8.0-rc2/hack/make/validate-lint (about)

     1  #!/bin/bash
     2  
     3  source "${MAKEDIR}/.validate"
     4  
     5  # We will eventually get to the point when packages should be the complete list
     6  # of subpackages, vendoring excluded, as given by:
     7  #
     8  # packages=( $(go list ./... 2> /dev/null | grep -vE "^github.com/docker/docker/vendor" || true ) )
     9  
    10  packages=(
    11  	builder
    12  	builder/command
    13  	builder/parser
    14  	builder/parser/dumper
    15  	daemon/events
    16  	daemon/execdriver/native/template
    17  	daemon/network
    18  	docker
    19  	dockerinit
    20  	integration-cli
    21  	pkg/chrootarchive
    22  	pkg/directory
    23  	pkg/fileutils
    24  	pkg/homedir
    25  	pkg/listenbuffer
    26  	pkg/mflag/example
    27  	pkg/mount
    28  	pkg/namesgenerator
    29  	pkg/nat
    30  	pkg/promise
    31  	pkg/pubsub
    32  	pkg/random
    33  	pkg/reexec
    34  	pkg/symlink
    35  	pkg/timeutils
    36  	pkg/tlsconfig
    37  	pkg/urlutil
    38  	pkg/version
    39  	registry
    40  	utils
    41  )
    42  
    43  errors=()
    44  for p in "${packages[@]}"; do
    45  	# Run golint on package/*.go file explicitly to validate all go files
    46  	# and not just the ones for the current platform.
    47  	failedLint=$(golint "$p"/*.go)
    48  	if [ "$failedLint" ]; then
    49  		errors+=( "$failedLint" )
    50  	fi
    51  done
    52  
    53  if [ ${#errors[@]} -eq 0 ]; then
    54  	echo 'Congratulations!  All Go source files have been linted.'
    55  else
    56  	{
    57  		echo "Errors from golint:"
    58  		for err in "${errors[@]}"; do
    59  			echo "$err"
    60  		done
    61  		echo
    62  		echo 'Please fix the above errors. You can test via "golint" and commit the result.'
    63  		echo
    64  	} >&2
    65  	false
    66  fi