Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: golangci-lint

on:
pull_request:
push:
branches:
- main
- master

env:
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v2.0

jobs:
detect-modules:
runs-on: ubuntu-latest
outputs:
modules: ${{ steps.set-modules.outputs.modules }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- id: set-modules
run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT

golangci-lint:
needs: detect-modules
runs-on: ubuntu-latest
env:
GOPRIVATE: "github.com/iamgoroot/*"
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
strategy:
matrix:
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- run: git config --global url.https://$GITHUB_TOKEN:x-oauth-basic@github.com/.insteadOf https://github.com/

- name: golangci-lint ${{ matrix.modules }}
uses: golangci/golangci-lint-action@v7
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: ${{ matrix.modules }}
181 changes: 97 additions & 84 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,99 +1,112 @@
version: "2"
linters:
enable:
- bodyclose
- errcheck
- goconst
- gocritic
- gofmt
- goimports
- mnd
- goprintffuncname
- misspell
- nilerr
- staticcheck
- stylecheck
- unconvert
- unparam
- whitespace
- gosimple
- unused
- asasalint
- sqlclosecheck
- noctx
- prealloc
- rowserrcheck
- wsl
- ineffassign
- durationcheck
- testpackage
- paralleltest
- copyloopvar
- funlen
- forcetypeassert
- fatcontext
- bodyclose
- canonicalheader
- copyloopvar
- cyclop
- decorder
- dupl
- durationcheck
- err113
- fatcontext
- forcetypeassert
- funlen
- gocheckcompilerdirectives
- goconst
- gocritic
- gocyclo
- grouper
- varnamelen
- unconvert
- godot
- gomoddirectives
- goprintffuncname
- gosec
- grouper
- lll
linters-settings:
gocritic:
enable-all: true
lll:
line-length: 140
varnamelen:
ignore-names:
- tx
- db
govet:
enable:
- appends
- asmdecl
- assign
- atomic
- atomicalign
- bools
- buildtag
- cgocall
- composites
- copylocks
- deepequalerrors
- defers
- directive
- errorsas
- fieldalignment
- findcall
- framepointer
- httpresponse
- ifaceassert
- loopclosure
- lostcancel
- nilfunc
- nilness
- printf
- reflectvaluecompare
- shadow
- shift
- sigchanyzer
- slog
- sortslice
- stdmethods
- stringintconv
- structtag
- testinggoroutine
- tests
- unmarshal
- unreachable
- unsafeptr
- unusedresult
- unusedwrite
- misspell
- mnd
- nilerr
- noctx
- paralleltest
- prealloc
- rowserrcheck
- sqlclosecheck
- staticcheck
- testpackage
- unconvert
- unparam
- varnamelen
- whitespace
- wsl
settings:
gocritic:
enable-all: true
govet:
enable:
- appends
- asmdecl
- assign
- atomic
- atomicalign
- bools
- buildtag
- cgocall
- composites
- copylocks
- deepequalerrors
- defers
- directive
- errorsas
- fieldalignment
- findcall
- framepointer
- httpresponse
- ifaceassert
- loopclosure
- lostcancel
- nilfunc
- nilness
- printf
- reflectvaluecompare
- shadow
- shift
- sigchanyzer
- slog
- sortslice
- stdmethods
- stringintconv
- structtag
- testinggoroutine
- tests
- unmarshal
- unreachable
- unsafeptr
- unusedresult
- unusedwrite
lll:
line-length: 140
varnamelen:
ignore-names:
- tx
- db
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ update:
generate:
go list -f '{{.Dir}}/...' -m | xargs go generate
lint:
go list -f '{{.Dir}}/...' -m | xargs go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run -j 4 --allow-parallel-runner -v --fix -c .golangci.yaml
go list -f '{{.Dir}}/...' -m | xargs golangci-lint run -j 4 -v --fix -c .golangci.yaml
structalign:
go list -f '{{.Dir}}' -m | xargs -I {} sh -c 'cd {} && go run golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment -fix ./...'
15 changes: 10 additions & 5 deletions examples/distributed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ func main() {
//KeyValStore: &kv.PgKV{}, // use postgres KV store explicitly. import "github.com/iamgoroot/backline/pkg/store/kv"
//KeyValStore: &kv.SqliteKV{}, // use postgres KV store explicitly. import "github.com/iamgoroot/backline/pkg/store/kv"

JobScheduler: &store.Scheduler{}, // job scheduler plugin. Basic implementation that uses KV store and Locker for scheduling and synchronizing tasks
DistributedLocker: &store.Locker{}, // distributed lock plugin configurable with config file. Uses pg_try_advisory_xact_lock for pg and sql table with transaction is used for sqlite

SearchPlugin: &elastic.Search{}, // add search plugin based on elastic search. import "github.com/iamgoroot/backline/plugin/search/elastic"
//SearchPlugin: &bluge.Search{}, // add search plugin based on bluge library (storing indices in local file). import "github.com/iamgoroot/backline/plugin/search/bluge"
// job scheduler plugin. Basic implementation that uses KV store and Locker for scheduling and synchronizing tasks
JobScheduler: &store.Scheduler{},
// distributed lock plugin configurable with config file.
// Uses pg_try_advisory_xact_lock for pg or sql table with transaction for sqlite
DistributedLocker: &store.Locker{},
// add search plugin based on elastic search. import "github.com/iamgoroot/backline/plugin/search/elastic"
SearchPlugin: &elastic.Search{},

// add search plugin based on bluge library (storing indices in local file). import "github.com/iamgoroot/backline/plugin/search/bluge"
//SearchPlugin: &bluge.Search{},

ScannerPlugin: &scanner.Plugin{}, // add scanner plugin to scan/read entities.
},
Expand Down
18 changes: 12 additions & 6 deletions examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ func main() {
// run catalog and scanner

PluggableDeps: app.PluggableDeps{
EntityDiscoveries: []core.Discovery{ // Add Location Readers so backline knows how to read entities from different sources
// add Location Readers so backline knows how to read entities from different sources
EntityDiscoveries: []core.Discovery{
&fs.Discovery{}, // directory to search entities
},
EntityRepo: &pg.Repo{}, // use postgres implementation explicitly. import "github.com/iamgoroot/backline/pkg/store/repo/pg"
KeyValStore: &kv.PgKV{}, // use postgres KV store explicitly. import "github.com/iamgoroot/backline/pkg/store/kv"
JobScheduler: &store.Scheduler{}, // job scheduler plugin. Basic implementation that uses KV store and Locker for scheduling and synchronizing tasks
DistributedLocker: &store.Locker{}, // distributed lock plugin configurable with config file. Uses pg_try_advisory_xact_lock for pg and sql table with transaction is used for sqlite
ScannerPlugin: &scanner.Plugin{}, // add scanner plugin to scan/read entities.
EntityRepo: &pg.Repo{}, // use postgres implementation explicitly.
// use postgres KV store explicitly.
KeyValStore: &kv.PgKV{},
// job scheduler plugin. Basic implementation that uses KV store and Locker for scheduling and synchronizing tasks
JobScheduler: &store.Scheduler{},
// distributed lock plugin configurable with config file.
// uses pg_try_advisory_xact_lock for pg or sql table with transaction for sqlite
DistributedLocker: &store.Locker{},
// add scanner plugin to scan/read entities.
ScannerPlugin: &scanner.Plugin{},
},
Plugins: []core.Plugin{
catalog.Plugin{}, // add web interface for catalog
Expand Down
12 changes: 0 additions & 12 deletions examples/split/scan_service/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,3 @@ require (
modernc.org/memory v1.9.1 // indirect
modernc.org/sqlite v1.37.0 // indirect
)

//TODO: remove
replace (
github.com/iamgoroot/backline/app => ./../../../app
github.com/iamgoroot/backline/pkg => ./../../../pkg
github.com/iamgoroot/backline/plugin/catalog => ./../../../plugin/catalog
github.com/iamgoroot/backline/plugin/discovery/fs => ./../../../plugin/discovery/fs
github.com/iamgoroot/backline/plugin/discovery/github => ./../../../plugin/discovery/github
github.com/iamgoroot/backline/plugin/documentation/techdocs => ./../../../plugin/documentation/techdocs
github.com/iamgoroot/backline/plugin/scanner => ./../../../plugin/scanner

)
2 changes: 1 addition & 1 deletion pkg/store/kv/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (m *PgKV) Setup(ctx context.Context, deps core.Dependencies) error {
m.DB = db
m.bunKV = bunKV{db: db, logger: deps.Logger()}

return m.bunKV.setup(ctx)
return m.setup(ctx)
}

func (m *PgKV) getDB(deps core.Dependencies) (*bun.DB, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/kv/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (m *SqliteKV) Setup(ctx context.Context, deps core.Dependencies) error {
db := bun.NewDB(sqldb, sqlitedialect.New())
m.bunKV = bunKV{db: db, logger: deps.Logger()}

return m.bunKV.setup(ctx)
return m.setup(ctx)
}

func (m *SqliteKV) Shutdown(ctx context.Context) error {
Expand Down
Loading