Skip to content

Commit 3831b54

Browse files
committed
feat(code-quality): add and run tools, update go
1 parent fb393b1 commit 3831b54

22 files changed

+132
-77
lines changed

.devcontainer/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM mcr.microsoft.com/devcontainers/go:1-1-bullseye
2+
3+
# Python environment
4+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5+
&& apt-get -y install python3-pip git zlib1g-dev unzip
6+
7+
# Pre-Commit to run pre-commit tools
8+
RUN pip3 install pre-commit

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
{
44
"name": "Go",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/devcontainers/go:1-1-bullseye",
6+
"build": {
7+
"dockerfile": "Dockerfile"
8+
},
79
"customizations": {
810
"vscode": {
911
"extensions": [

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ cli/.vscode
55
.vscode/launch.json
66
pkg/
77
bin
8-
.env
8+
.env

.pre-commit-config.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Pre-Commit
2+
# https://pre-commit.com
3+
# Run formatter and more before git commit.
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.6.0
7+
hooks:
8+
- id: trailing-whitespace
9+
- id: end-of-file-fixer
10+
- id: detect-private-key
11+
- id: check-merge-conflict
12+
- repo: local
13+
hooks:
14+
- id: gofmt
15+
name: gofmt
16+
language: golang
17+
entry: fmt
18+
files: \.go$
19+
require_serial: true
20+
- repo: local
21+
hooks:
22+
- id: goimports
23+
name: goimports
24+
language: golang
25+
entry: goimports
26+
files: \.go$
27+
args:
28+
- -w
29+
require_serial: true
30+
- repo: https://github.com/golangci/golangci-lint
31+
rev: v1.59.1
32+
hooks:
33+
- id: golangci-lint
34+
exclude: ^pkg/

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"gopls": {
33
"ui.semanticTokens": true
4-
}
4+
},
5+
"go.lintTool": "golangci-lint",
6+
"go.lintFlags": [
7+
"--fast"
8+
]
59
}

ERRORs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
12334
44
│││││
55
││││└─ Error Reason
6-
│││└── Data Type
6+
│││└── Data Type
77
││└─── Class
88
│└──── Module
99
```
@@ -37,4 +37,4 @@
3737
## Module
3838

3939
| Code | Alternative | Explanation |
40-
|------|-------------|-------------|
40+
|------|-------------|-------------|

MAKEFILE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ If you want to see the Documentation: `make doc` - Warning: A browser window wil
1616
- Check files with gosec: `make checksec`
1717
- Open the repo in github: `make github`.
1818
- See changes: `make diff`
19-
- Clean dependencies and precompiled code: `make clean`
19+
- Clean dependencies and precompiled code: `make clean`

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GOPATH = $(shell go env GOPATH)
22

33
# Test SDK
4-
test:
4+
test:
55
cd test; go test -v
66

77
# GO SDK
@@ -11,15 +11,15 @@ sdk: *.go
1111
# CLI App
1212
$(GOPATH)/bin/sqlc: *.go cli/sqlc.go
1313
cd cli; go build -o $(GOPATH)/bin/sqlc
14-
14+
1515
cli: $(GOPATH)/bin/sqlc
1616

1717
github:
18-
open https://github.com/sqlitecloud/sqlitecloud-go
19-
18+
open https://github.com/sqlitecloud/sqlitecloud-go
19+
2020
diff:
2121
git difftool
22-
22+
2323

2424
# gosec
2525
gosec:
@@ -40,15 +40,15 @@ endif
4040

4141
doc: godoc
4242
ifeq ($(wildcard ./src),)
43-
ln -s . src
43+
ln -s . src
4444
endif
4545
@echo "Hit CRTL-C to stop the documentation server..."
4646
@( sleep 1 && open http://localhost:6060/pkg/github.com/sqlitecloud/sqlitecloud-go/ ) &
4747
@$(GOPATH)/bin/godoc -http=:6060 -index -play
4848

4949
clean:
50-
rm -rf $(GOPATH)/bin/sqlc*
50+
rm -rf $(GOPATH)/bin/sqlc*
5151

5252
all: sdk cli test
5353

54-
.PHONY: test sdk
54+
.PHONY: test sdk

PUBSUB.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ SQLiteCloud listens to a default port (default 8860) where clients can connect (
88

99
When a client send the first **LISTEN channel** command a special reply is sent back to it. This reply is a special command that must be re-executed as is on server side. Command is:
1010

11-
**PAUTH** **client_uuid** **client_secret**
11+
**PAUTH** **client_uuid** **client_secret**
1212

1313
- When executed on **client-side**, the client opens a new connection to the server and a new thread is created listening for read events on this new socket.
1414
- When executed on **server-side**, client is recognized (using uuid) and authenticated (using secret) and its pubsub socket is set to the current socket used by this new connection. This socket will be used exclusively to deliver notifications. Socket flow is different from the default one because it involves WRITE operations only.
1515

1616
The following commands are related to PUB/SUB:
1717

18-
1. **LISTEN channel**: registers the current client as a listener on the notification channel named `channel`. If the current session is already registered as a listener for this notification channel, nothing is done. If channel has the same name of the current database (if any) table then all WRITE operations will be notified. If channel is `*` the all WRITE operations of all the tables of the current database (if any) will be notified. LISTEN takes effect at transaction commit. If channel is not `*` and it is not the name of table in the current database (if any), then it represents a named channel that can be notified only by NOTIFY channel commands.
18+
1. **LISTEN channel**: registers the current client as a listener on the notification channel named `channel`. If the current session is already registered as a listener for this notification channel, nothing is done. If channel has the same name of the current database (if any) table then all WRITE operations will be notified. If channel is `*` the all WRITE operations of all the tables of the current database (if any) will be notified. LISTEN takes effect at transaction commit. If channel is not `*` and it is not the name of table in the current database (if any), then it represents a named channel that can be notified only by NOTIFY channel commands.
1919
2. **UNLISTEN channel**: remove an existing registration for `NOTIFY` events. `UNLISTEN` cancels any existing registration of the current SQLiteCloud session as a listener on the notification channel named `channel`. The special wildcard `*` cancels all listener registrations for the current session.
2020
3. **NOTIFY channel [, payload]**: The `NOTIFY` command sends a notification event together with an optional "payload" string to each client application that has previously executed `LISTEN channel` for the specified channel name in the current database. The payload (if any) is broadcast as is to all other connections without any modification on server side.
2121

@@ -140,4 +140,4 @@ UPDATE foo SET id=14,col1='test200' WHERE id=15;
140140
"col2": "test101"
141141
}]
142142
}
143-
```
143+
```

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The SQLite Cloud Client SDK for Go (sqlitecloud/go-sdk) is the Go Programming La
1616
2. Download the package, and run the [`go mod tidy` command](https://go.dev/ref/mod#go-mod-tidy) to synchronize your module's dependencies:
1717

1818
```
19-
$ go mod tidy
19+
$ go mod tidy
2020
go: downloading github.com/sqlitecloud/sqlitecloud-go v1.0.0
2121
```
2222

@@ -81,4 +81,4 @@ To get a valid connection string, follow these instructions:
8181

8282
## API Documentation
8383

84-
The complete documentation of the sqlitecloud/go-sdk library is available at: https://pkg.go.dev/github.com/sqlitecloud/sqlitecloud-go
84+
The complete documentation of the sqlitecloud/go-sdk library is available at: https://pkg.go.dev/github.com/sqlitecloud/sqlitecloud-go

0 commit comments

Comments
 (0)