Skip to content

Commit 0e4998b

Browse files
committed
move code from golangci-worker to golangci-lint
1 parent cd8b117 commit 0e4998b

29 files changed

+1649
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

Gopkg.lock

Lines changed: 150 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Gopkg.toml example
2+
#
3+
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4+
# for detailed Gopkg.toml documentation.
5+
#
6+
# required = ["github.com/user/thing/cmd/thing"]
7+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8+
#
9+
# [[constraint]]
10+
# name = "github.com/user/project"
11+
# version = "1.0.0"
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project2"
15+
# branch = "dev"
16+
# source = "github.com/myfork/project2"
17+
#
18+
# [[override]]
19+
# name = "github.com/x/y"
20+
# version = "2.4.0"
21+
#
22+
# [prune]
23+
# non-go = false
24+
# go-tests = true
25+
# unused-packages = true
26+
27+
28+
[[constraint]]
29+
name = "github.com/bradleyfalzon/revgrep"
30+
version = "0.3.0"
31+
32+
[[constraint]]
33+
name = "github.com/golang/mock"
34+
version = "1.1.1"
35+
36+
[[constraint]]
37+
branch = "master"
38+
name = "github.com/golangci/golangci-shared"
39+
40+
[[constraint]]
41+
name = "github.com/stretchr/testify"
42+
version = "1.2.1"
43+
44+
[[constraint]]
45+
branch = "master"
46+
name = "sourcegraph.com/sourcegraph/go-diff"
47+
48+
[prune]
49+
go-tests = true
50+
unused-packages = true

cmd/golangci-lint/main.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"log"
6+
"os"
7+
"path/filepath"
8+
9+
"github.com/golangci/golangci-lint/pkg/config"
10+
"github.com/golangci/golangci-lint/pkg/golinters"
11+
"github.com/golangci/golangci-shared/pkg/executors"
12+
)
13+
14+
func main() {
15+
if err := run(); err != nil {
16+
panic(err)
17+
}
18+
}
19+
20+
func run() error {
21+
var cfg config.Config
22+
config.ReadFromCommandLine(&cfg)
23+
24+
linters := golinters.GetSupportedLinters()
25+
ctx := context.Background()
26+
27+
ex, err := os.Executable()
28+
if err != nil {
29+
return err
30+
}
31+
exPath := filepath.Dir(ex)
32+
exec := executors.NewShell(exPath)
33+
34+
for _, linter := range linters {
35+
res, err := linter.Run(ctx, exec)
36+
if err != nil {
37+
return err
38+
}
39+
log.Print(res)
40+
}
41+
42+
return nil
43+
}

pkg/config/command_line.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package config
2+
3+
import "flag"
4+
5+
func ReadFromCommandLine(cfg *Config) {
6+
flag.Parse()
7+
paths := flag.Args()
8+
if len(paths) != 0 {
9+
cfg.Paths = paths
10+
}
11+
}

pkg/config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package config
2+
3+
type Config struct {
4+
Paths []string
5+
}

pkg/fsutils/fsutils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package fsutils
2+
3+
import (
4+
"go/build"
5+
"path"
6+
)
7+
8+
func GetProjectRoot() string {
9+
return path.Join(build.Default.GOPATH, "src", "github.com", "golangci", "golangci-worker")
10+
}

0 commit comments

Comments
 (0)