Skip to content

Commit

Permalink
deprecate <1.12.x, use golangci-lint (spf13#876)
Browse files Browse the repository at this point in the history
* deprecate go 1.10.x and 1.11.x
* use golangci-lint in Travis CI
* fix linting issues accordingly
  • Loading branch information
umarcor committed Oct 2, 2019
1 parent f546492 commit e118d75
Show file tree
Hide file tree
Showing 32 changed files with 442 additions and 548 deletions.
9 changes: 1 addition & 8 deletions .circleci/config.yml
Expand Up @@ -8,6 +8,7 @@ references:
run:
name: "All Commands"
command: |
export GO111MODULE=on
mkdir -p bin
curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.6/shellcheck
chmod +x bin/shellcheck
Expand All @@ -29,13 +30,6 @@ jobs:
- run:
name: "Check formatting"
command: diff -u <(echo -n) <(gofmt -d -s .)
go-previous:
docker:
- image: circleci/golang:1.11
working_directory: *workspace
steps:
- checkout
- *run_tests
go-latest:
docker:
- image: circleci/golang:latest
Expand All @@ -49,5 +43,4 @@ workflows:
main:
jobs:
- go-current
- go-previous
- go-latest
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -33,7 +33,11 @@ tags

*.exe
cobra
!cobra/
cobra.test

.idea/
*.iml

# test-generated files
cobra/cmd/testproject
25 changes: 25 additions & 0 deletions .golangci.yml
@@ -0,0 +1,25 @@
run:
deadline: 5m

linters:
enable:
- deadcode
- errcheck
- gas
- goconst
- goimports
- golint
- govet
- ineffassign
- interfacer
- maligned
- megacheck
- structcheck
- unconvert
- varcheck
enable-all: false
disable-all: true
# presets:
# - bugs
# - unused
fast: false
28 changes: 12 additions & 16 deletions .travis.yml
@@ -1,31 +1,27 @@
language: go

stages:
- diff
- lint
- test

go:
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
- tip

env:
- GO111MODULE=on

matrix:
allow_failures:
- go: tip
include:
- stage: diff
go: 1.12.x
script: diff -u <(echo -n) <(gofmt -d -s .)
env: GO111MODULE=on

before_install: go get -u github.com/kyoh86/richgo

script:
- richgo test -v ./...
- go build
- if [ -z $NOVET ]; then
diff -u <(echo -n) <(go vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint');
fi

matrix:
allow_failures:
- go: tip
include:
- stage: lint
go: 1.12.x
before_install: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest
script: golangci-lint run -v
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -211,7 +211,6 @@ import (
"fmt"
"os"

homedir "github.com/mitchellh/go-homedir"
"github.com/umarcor/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -239,7 +238,7 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
home, err := os.UserHomeDir()
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
12 changes: 7 additions & 5 deletions args_test.go
Expand Up @@ -38,8 +38,8 @@ func checkOutput(o string, t *testing.T, i string) {
}
}

func expectErrorAndCheckOutput(t *testing.T, err error, err_k, o, i string) {
// expectError(err, t, err_k)
func expectErrorAndCheckOutput(t *testing.T, err error, errK, o, i string) {
// expectError(err, t, errK)
// checkOutput(o, t, i)
}

Expand Down Expand Up @@ -238,19 +238,21 @@ func TestChildTakesArgs(t *testing.T) {
}
}

/*
// NOTE 'c [command]' is not shown because this command does not have any subcommand
// NOTE 'Valid Args:' is not shown because this command is not runnable
// NOTE 'c [flags]' is not shown because this command is not runnable
func noRunChecks(t *testing.T, err error, err_k, o string) {
expectErrorAndCheckOutput(t, err, err_k, o, "u")
func noRunChecks(t *testing.T, err error, errK, o string) {
expectErrorAndCheckOutput(t, err, errK, o, "u")
}
*/

// NoRun (no children)

func TestArgs_NoRun(t *testing.T) {
tc := argsTestcase{"run", nil, false, false, []string{}}
t.Run("|", tc.test)
// noRunChecks(t, e, "run", o)
//noRunChecks(t, e, "run", o)
}

func TestArgs_NoRun_ArbValid(t *testing.T) {
Expand Down

0 comments on commit e118d75

Please sign in to comment.