Merge pull request #799 from endocode/krnowak/more-gofmt-and-govet

Check more packages with gofmt and go vet
This commit is contained in:
Krzesimir Nowak
2015-04-28 13:16:21 +02:00
4 changed files with 41 additions and 8 deletions
+36 -3
View File
@@ -14,8 +14,37 @@ COVER=${COVER:-"-cover"}
source ./build
TESTABLE_AND_FORMATTABLE="pkg/keystore pkg/lock pkg/tar rkt rkt/config stage1/init store"
FORMATTABLE="$TESTABLE_AND_FORMATTABLE common networking stage0/run.go version"
function find_dirs_with_suffixed_files
{
# File suffix, can contain dots, asterisks and question marks -
# they will be escaped. Use of other metacharacters is at your own
# risk.
local suffix="$1"
# Escape question mark and asterisk metacharacters from suffix, so
# they are matched literally in find command.
local find_escaped_suffix=$(echo "${suffix}" | sed -e 's/\([?*]\)/\\\1/g')
# Escape dot and asterisk metacharacters from suffix, so they are
# matched literally in sed 's' command.
local sed_escaped_suffix=$(echo "${suffix}" | sed -e 's/\([.*]\)/\\\1/g')
# Variable 'exclude' is an POSIX ERE fragment to be put between
# '^(' and ')$'.
local exclude="$2"
# Find all files ending with given suffix, ...
find . -name '*'"${find_escaped_suffix}" |
# ... remove files with given suffix together with preceding slash, ...
sed -e 's/\/[[:alnum:]_]\+'"${sed_escaped_suffix}"'//g' |
# ... remove leading './', ...
sed -e 's/^\.\///g' |
# ... sort alphabetically, ...
sort |
# ... remove repeated directories, ...
uniq |
# ... and filter out given directories.
grep -vEe '^('"${exclude}"')$'
}
TESTABLE_AND_FORMATTABLE=$(find_dirs_with_suffixed_files '_test.go' 'Godeps/.*|tests')
FORMATTABLE=$(find_dirs_with_suffixed_files '.go' 'Godeps/.*')
# user has not provided PKG override
if [ -z "$PKG" ]; then
@@ -47,8 +76,12 @@ if [ -n "${fmtRes}" ]; then
exit 255
fi
# split FMT into an array and prepend REPO_PATH to each local package for go vet
split_vet=(${FMT// / })
VET_TEST=${split_vet[@]/#/${REPO_PATH}/}
echo "Checking govet..."
vetRes=$(go vet $TEST)
vetRes=$(go vet $VET_TEST)
if [ -n "${vetRes}" ]; then
echo -e "govet checking failed:\n${vetRes}"
exit 255
+1 -1
View File
@@ -63,7 +63,7 @@ func main() {
globalFlagset.Parse(os.Args[1:])
args := globalFlagset.Args()
if len(args) > 0 {
fmt.Fprintln(os.Stderr, "Wrong parameters\n")
fmt.Fprintln(os.Stderr, "Wrong parameters")
os.Exit(1)
}
+3 -3
View File
@@ -48,9 +48,9 @@ const (
)
type genericAuthTest struct {
name string
confDir authConfDir
expectedLine string
name string
confDir authConfDir
expectedLine string
}
func TestAuthBasic(t *testing.T) {
+1 -1
View File
@@ -229,7 +229,7 @@ func NewServerWithPaths(auth Type, msgCapacity int, acTool, goTool string) (*Ser
func getTool(tool string) (string, error) {
toolPath, err := exec.LookPath(tool)
if err != nil {
return "", fmt.Errorf("failed to find %s in $PATH: $v", tool, err)
return "", fmt.Errorf("failed to find %s in $PATH: %v", tool, err)
}
absToolPath, err := filepath.Abs(toolPath)
if err != nil {