Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit 70229ed

Browse files
flosellrodaine
authored andcommitted
Make script/test more robust (#13)
* Make script/test more robust when dealing with different golang versions or golint not installed (e.g. in travis-ci) Co-authored-by: Lucas Kacher <[email protected]> * Use Go 1.11 in travis-ci since golint doesn't support old versions * Rename to avoid shadowing existing variable
1 parent cd6ee75 commit 70229ed

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sudo: false
22
language: go
3-
go: 1.6
3+
go: 1.11
44

55
install: go get -t ./...
66
script: ./script/test

nodes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ func encodeStruct(in reflect.Value) (ast.Node, []*ast.ObjectKey, error) {
277277
itemKey := &ast.ObjectKey{Token: tkn}
278278

279279
// if the item is an object list, we need to flatten out the items
280-
if val, ok := val.(*ast.ObjectList); ok {
281-
for _, obj := range val.Items {
280+
if objectList, ok := val.(*ast.ObjectList); ok {
281+
for _, obj := range objectList.Items {
282282
objectKeys := append([]*ast.ObjectKey{itemKey}, obj.Keys...)
283283
list.Add(&ast.ObjectItem{
284284
Keys: objectKeys,

script/test

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ set -e
44
echo "go fmt..."
55
test -z "$(gofmt -l -w . | tee /dev/stderr)"
66

7+
if ! [ -x "$(command -v golint)" ]; then
8+
echo "installing golint..."
9+
go get -u golang.org/x/lint/golint
10+
fi
11+
712
echo "go lint..."
813
test -z "$(golint ./... | tee /dev/stderr)"
914

1015
echo "go vet..."
11-
test -z "$(go tool vet -test . 2>&1 | tee /dev/stderr)"
16+
test -z "$(go tool vet -all -shadow . 2>&1 | tee /dev/stderr)"
1217

1318
echo "go test..."
1419
go test -race -cover ./...

0 commit comments

Comments
 (0)