Skip to content

Commit

Permalink
Merge pull request #949 from go-kivik/gomodv2
Browse files Browse the repository at this point in the history
Take 2 at a separate Go mod for x/sqlite
  • Loading branch information
flimzy committed Apr 25, 2024
2 parents 6bfd14d + c4b4ea1 commit a146daa
Show file tree
Hide file tree
Showing 44 changed files with 541 additions and 123 deletions.
17 changes: 17 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ variables:
COUCHDB_USER: admin
COUCHDB_PASSWORD: abc123

test-x-sqlite:
stage: test
image: golang:1.22
script:
- cd x/sqlite
- go mod download
- go test -race -shuffle=on ./...

linter-x-sqlite:
stage: test
image: golangci/golangci-lint:v1.57.2
script:
- cd x/sqlite
- go mod download
- golangci-lint run ./...
- go mod tidy && git diff --exit-code

test:
parallel:
matrix:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ Install Kivik as you normally would for any Go package:

This will install the main Kivik package and the CouchDB database driver. Three officially supported drivers are shipped with this Go module:

- CouchDB: https://github.com/go-kivik/kivik/v4/couchdb
- PouchDB: https://github.com/go-kivik/kivik/v4/pouchdb (requires GopherJS)
- MockDB: https://github.com/go-kivik/kivik/v4/mockdb
- CouchDB: [github.com/go-kivik/kivik/v4/couchdb](https://pkg.go.dev/github.com/go-kivik/kivik/v4/couchdb)
- PouchDB: [github.com/go-kivik/kivik/v4/pouchdb](https://pkg.go.dev/github.com/go-kivik/kivik/v4/pouchdb) (requires GopherJS)
- MockDB: [github.com/go-kivik/kivik/v4/mockdb](https://pkg.go.dev/github.com/go-kivik/kivik/v4/mockdb)

In addition, there are partial/experimental drivers available:

- FilesystemDB: https://github.com/go-kivik/kivik/v4/x/fsdb
- MemoryDB: https://github.com/go-kivik/kivik/v4/x/memorydb
- SQLite: https://github.com/go-kivik/kivik/v4/x/sqlite
- FilesystemDB: [github.com/go-kivik/kivik/v4/x/fsdb](https://pkg.go.dev/github.com/go-kivik/kivik/v4/x/fsdb)
- MemoryDB: [github.com/go-kivik/kivik/v4/x/memorydb](https://pkg.go.dev/github.com/go-kivik/kivik/v4/x/memorydb)
- SQLite: [github.com/go-kivik/kivik/x/sqlite/v4](https://pkg.go.dev/github.com/go-kivik/kivik/x/sqlite/v4)

# CLI

Expand Down
20 changes: 1 addition & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.17
require (
github.com/ajg/form v1.5.1
github.com/cenkalti/backoff/v4 v4.1.3
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204
github.com/go-chi/chi v1.5.5
github.com/go-chi/chi/v5 v5.0.10
github.com/go-playground/validator/v10 v10.16.0
Expand All @@ -24,23 +23,17 @@ require (
golang.org/x/net v0.17.0
golang.org/x/sync v0.4.0
gopkg.in/yaml.v3 v3.0.1
modernc.org/sqlite v1.20.4
)

require (
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -49,23 +42,12 @@ require (
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.9.3 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.41.0 // indirect
modernc.org/ccgo/v3 v3.16.15 // indirect
modernc.org/libc v1.37.6 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/strutil v1.1.3 // indirect
modernc.org/token v1.1.0 // indirect
)
67 changes: 0 additions & 67 deletions go.sum

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions x/sqlite/.golangci-safe.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[run]
timeout = "15s"
allow-parallel-runners = true

[output]
format = "colored-line-number"

[linters]
disable-all = true
enable = [
# Styling/formatting
"gci", # Handles import groups/ordering
"gofmt",
]

[issues]
fix = true
exclude-use-default = false

[linters-settings.gci]
sections = ["standard", "default", "prefix(github.com/go-kivik/kivik/)"]
skip-generated = false
custom-order = true
61 changes: 61 additions & 0 deletions x/sqlite/.golangci.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[run]
timeout = "300s"

[[output.formats]]
format = "colored-line-number"

[linters]
enable = [
"gci",
"unconvert",
"goimports",
"unused",
"vetshadow",
"misspell",
"nakedret",
"errcheck",
"revive",
"ineffassign",
"vet",
"unparam",
"gofumpt",
"prealloc",
"gocritic",
"staticcheck",
"goheader",

# SQL-related linters
"rowserrcheck",
"sqlclosecheck",
]

[issues]
exclude-use-default = false

[[issues.exclude-rules]]
source = "defer .*\\.(Close|Rollback)\\(\\)$"
linters = ["errcheck"]

[linters-settings.gci]
sections = ["standard", "default", "prefix(github.com/go-kivik/kivik)"]
skip-generated = false
custom-order = true

[linters-settings.goheader]
template = """
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http:https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License."""

# Prepared statements on transactions are closed by the transaction.
[[issues.exclude-rules]]
source = "tx.Prepare|stmts.prepare"
linters = ["sqlclosecheck"]
9 changes: 9 additions & 0 deletions x/sqlite/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"emeraldwalk.runonsave",
"tamasfe.even-better-toml",
"github.vscode-github-actions",
"codezombiech.gitignore",
"golang.go"
]
}
11 changes: 11 additions & 0 deletions x/sqlite/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"go.lintTool": "golangci-lint",
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.go$",
"cmd": "golangci-lint run -c ${workspaceFolder}/.golangci-safe.toml ${fileDirname} --fix"
}
]
}
}
2 changes: 1 addition & 1 deletion x/sqlite/changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

"github.com/go-kivik/kivik/v4"
"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal/mock"
"github.com/go-kivik/kivik/x/sqlite/v4/internal/mock"
)

func TestDBChanges(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"testing"

"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal/mock"
"github.com/go-kivik/kivik/x/sqlite/v4/internal/mock"
)

type DB interface {
Expand Down
4 changes: 4 additions & 0 deletions x/sqlite/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ func (db) BulkDocs(context.Context, []interface{}, driver.Options) ([]driver.Bul
func (db) Copy(context.Context, string, string, driver.Options) (string, error) {
return "", nil
}

func (db) CreateDoc(context.Context, interface{}, driver.Options) (string, string, error) {
return "", "", nil
}
2 changes: 1 addition & 1 deletion x/sqlite/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"net/http"

"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal"
"github.com/go-kivik/kivik/x/sqlite/v4/internal"
)

func (d *db) Delete(ctx context.Context, docID string, options driver.Options) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/go-kivik/kivik/v4"
"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal/mock"
"github.com/go-kivik/kivik/x/sqlite/v4/internal/mock"
)

func TestDBDelete(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/deleteattachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"net/http"

"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal"
"github.com/go-kivik/kivik/x/sqlite/v4/internal"
)

func (d *db) DeleteAttachment(ctx context.Context, docID, filename string, options driver.Options) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/deleteattachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/go-kivik/kivik/v4"
"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal/mock"
"github.com/go-kivik/kivik/x/sqlite/v4/internal/mock"
)

func TestDBDeleteAttachment(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/designdocs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/go-kivik/kivik/v4"
"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal/mock"
"github.com/go-kivik/kivik/x/sqlite/v4/internal/mock"
)

func TestDBDesignDocs(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/go-kivik/kivik/v4"
"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal/mock"
"github.com/go-kivik/kivik/x/sqlite/v4/internal/mock"
)

func TestDBGet(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/getattachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"net/http"

"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal"
"github.com/go-kivik/kivik/x/sqlite/v4/internal"
)

func (d *db) GetAttachment(ctx context.Context, docID string, filename string, options driver.Options) (*driver.Attachment, error) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/getattachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/go-kivik/kivik/v4"
"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal/mock"
"github.com/go-kivik/kivik/x/sqlite/v4/internal/mock"
)

func TestDBGetAttachment(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/getattachmentmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"net/http"

"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal"
"github.com/go-kivik/kivik/x/sqlite/v4/internal"
)

func (d *db) GetAttachmentMeta(ctx context.Context, docID, filename string, options driver.Options) (*driver.Attachment, error) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/getattachmentmeta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

"github.com/go-kivik/kivik/v4"
"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal/mock"
"github.com/go-kivik/kivik/x/sqlite/v4/internal/mock"
)

func TestDBGetAttachmentMeta(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/getrev.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"net/http"

"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal"
"github.com/go-kivik/kivik/x/sqlite/v4/internal"
)

func (d *db) GetRev(ctx context.Context, id string, options driver.Options) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion x/sqlite/getrev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/go-kivik/kivik/v4"
"github.com/go-kivik/kivik/v4/driver"
"github.com/go-kivik/kivik/v4/internal/mock"
"github.com/go-kivik/kivik/x/sqlite/v4/internal/mock"
)

func TestGetRev(t *testing.T) {
Expand Down
37 changes: 37 additions & 0 deletions x/sqlite/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module github.com/go-kivik/kivik/x/sqlite/v4

go 1.22.0

require (
github.com/cenkalti/backoff/v4 v4.3.0
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204
github.com/go-kivik/kivik/v4 v4.2.1
github.com/google/go-cmp v0.6.0
gitlab.com/flimzy/testy v0.14.0
modernc.org/sqlite v1.29.8
)

require (
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.13.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.49.3 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
)
Loading

0 comments on commit a146daa

Please sign in to comment.