-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
326 additions
and
309 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/go-queryset | ||
/vendor | ||
/internal/parser/test/tmptestdir*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
run: | ||
skip-dirs: | ||
- ^internal/parser/test/tmptestdir.* | ||
|
||
linters-settings: | ||
govet: | ||
check-shadowing: true | ||
golint: | ||
min-confidence: 0 | ||
gocyclo: | ||
min-complexity: 15 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
lll: | ||
line-length: 140 | ||
|
||
linters: | ||
enable-all: true | ||
disable: | ||
- scopelint | ||
- gochecknoglobals | ||
- gosec | ||
|
||
issues: | ||
exclude-rules: | ||
- linters: | ||
- unparam | ||
text: always receives | ||
- linters: | ||
- staticcheck | ||
text: "SA9003:" | ||
|
||
# golangci.com configuration | ||
# https://github.com/golangci/golangci/wiki/Configuration | ||
# service: | ||
# golangci-lint-version: 1.14.0 # use fixed version to not introduce new linters unexpectedly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
language: go | ||
go: | ||
- 1.8.x | ||
- 1.9.x | ||
- 1.11.x | ||
- 1.12.x | ||
before_install: | ||
- go get github.com/mattn/goveralls | ||
- go get github.com/alecthomas/gometalinter | ||
- go get github.com/golang/dep/cmd/dep | ||
- dep ensure -v | ||
- gometalinter --install --vendored-linters | ||
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.15.0 | ||
script: | ||
- make test | ||
- $HOME/gopath/bin/goveralls -ignore "queryset/test/autogenerated_models.go,examples/comparison/*/*.go,queryset/test/pkgimport/*.go,queryset/test/pkgimport/*/*/*.go" -v -service=travis-ci | ||
- $HOME/gopath/bin/goveralls -ignore "internal/queryset/generator/test/autogenerated_models.go,examples/comparison/*/*.go,internal/queryset/generator/test/pkgimport/*.go,internal/queryset/generator/test/pkgimport/*/*/*.go" -v -service=travis-ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"log" | ||
"strings" | ||
"path/filepath" | ||
"time" | ||
|
||
"github.com/jirfag/go-queryset/queryset" | ||
"github.com/jirfag/go-queryset/internal/parser" | ||
"github.com/jirfag/go-queryset/internal/queryset/generator" | ||
) | ||
|
||
func main() { | ||
const defaultOutPath = "autogenerated_{in}" | ||
|
||
inFile := flag.String("in", "models.go", "path to input file") | ||
outFile := flag.String("out", "autogenerated_{in}", "path to output file") | ||
outFile := flag.String("out", defaultOutPath, "path to output file") | ||
timeout := flag.Duration("timeout", time.Minute, "timeout for generation") | ||
flag.Parse() | ||
|
||
*outFile = strings.Replace(*outFile, "{in}", *inFile, 1) | ||
if err := queryset.GenerateQuerySets(*inFile, *outFile); err != nil { | ||
if *outFile == defaultOutPath { | ||
*outFile = filepath.Join(filepath.Dir(*inFile), "autogenerated_"+filepath.Base(*inFile)) | ||
} | ||
|
||
g := generator.Generator{ | ||
StructsParser: &parser.Structs{}, | ||
} | ||
|
||
ctx, finish := context.WithTimeout(context.Background(), *timeout) | ||
defer finish() | ||
|
||
if err := g.Generate(ctx, *inFile, *outFile); err != nil { | ||
log.Fatalf("can't generate query sets: %s", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.