Skip to content

Commit 0ffa5f2

Browse files
Merge pull request #18 from stackql/feature/format-requirements-compact
format-requirements
2 parents d4babbe + 82c5953 commit 0ffa5f2

14 files changed

Lines changed: 679 additions & 271 deletions

.claude/.gitignore

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

.github/workflows/build.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build and test
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
- 'build*'
8+
branches:
9+
- main
10+
- develop
11+
pull_request:
12+
branches:
13+
- main
14+
- develop
15+
16+
jobs:
17+
18+
test:
19+
name: test
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v2
26+
with:
27+
go-version: 1.17
28+
29+
- name: Unit tests
30+
run: |
31+
go mod tidy
32+
go test ./... -v

.github/workflows/lint.yaml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
name: CI
1+
name: Linting checks
22

33
on:
44
push:
5+
tags:
6+
- 'v*'
7+
- 'build*'
8+
- 'lint*'
9+
branches:
10+
- main
11+
- develop
12+
pull_request:
13+
branches:
14+
- main
15+
- develop
16+
17+
env:
18+
GOLANGCI_LINT_VERSION: ${{ vars.GOLANGCI_LINT_VERSION == '' && 'v2.5.0' || vars.GOLANGCI_LINT_VERSION }}
19+
DEFAULT_STEP_TIMEOUT: ${{ vars.DEFAULT_STEP_TIMEOUT_MIN == '' && '20' || vars.DEFAULT_STEP_TIMEOUT_MIN }}
520

621
jobs:
722

823
lint:
24+
name: lint
925
runs-on: ubuntu-latest
1026
steps:
1127
- uses: actions/checkout@v2
@@ -16,16 +32,23 @@ jobs:
1632
go-version: 1.17
1733

1834
- name: Restore bin
19-
uses: actions/cache@v2
35+
uses: actions/cache@v4
2036
with:
2137
path: ./bin
2238
key: ${{ runner.os }}-bin-${{ hashFiles('**/go.sum') }}
2339

2440
- name: Linting
25-
run: make lint
41+
run: |
42+
make lint GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION} | tee lint.log 2>&1 || true
43+
44+
- name: Upload linting results
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: lint-results
48+
path: lint.log
2649

2750
- name: Cache bin
28-
uses: actions/cache@v2
51+
uses: actions/cache@v4
2952
with:
3053
path: ./bin
3154
key: ${{ runner.os }}-bin-${{ hashFiles('**/go.sum') }}

.golangci.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
version: "2"
2+
output:
3+
formats:
4+
text:
5+
path: stdout
6+
linters:
7+
default: none
8+
enable:
9+
- asasalint
10+
- asciicheck
11+
- bidichk
12+
- bodyclose
13+
- cyclop
14+
- dupl
15+
- durationcheck
16+
- errcheck
17+
- errname
18+
- errorlint
19+
- exhaustive
20+
- forbidigo
21+
- funlen
22+
- gocheckcompilerdirectives
23+
- gochecknoglobals
24+
- gochecknoinits
25+
- gocognit
26+
# - goconst
27+
- gocritic
28+
- gocyclo
29+
- godot
30+
- gomodguard
31+
- goprintffuncname
32+
- gosec
33+
- govet
34+
- ineffassign
35+
- lll
36+
- loggercheck
37+
- makezero
38+
- mnd
39+
- musttag
40+
- nakedret
41+
- nestif
42+
- nilerr
43+
- nilnil
44+
# - noctx
45+
# - nolintlint
46+
- nonamedreturns
47+
- nosprintfhostport
48+
- predeclared
49+
- promlinter
50+
- reassign
51+
- revive
52+
- rowserrcheck
53+
- sqlclosecheck
54+
# - staticcheck
55+
- testableexamples
56+
- testpackage
57+
- tparallel
58+
- unconvert
59+
- unparam
60+
- unused
61+
- usestdlibvars
62+
- wastedassign
63+
- whitespace
64+
settings:
65+
cyclop:
66+
max-complexity: 30
67+
package-average: 10
68+
errcheck:
69+
check-type-assertions: true
70+
exhaustive:
71+
check:
72+
- switch
73+
- map
74+
exhaustruct:
75+
exclude:
76+
- ^net/http.Client$
77+
- ^net/http.Cookie$
78+
- ^net/http.Request$
79+
- ^net/http.Response$
80+
- ^net/http.Server$
81+
- ^net/http.Transport$
82+
- ^net/url.URL$
83+
- ^os/exec.Cmd$
84+
- ^reflect.StructField$
85+
- ^github.com/Shopify/sarama.Config$
86+
- ^github.com/Shopify/sarama.ProducerMessage$
87+
- ^github.com/mitchellh/mapstructure.DecoderConfig$
88+
- ^github.com/prometheus/client_golang/.+Opts$
89+
- ^github.com/spf13/cobra.Command$
90+
- ^github.com/spf13/cobra.CompletionOptions$
91+
- ^github.com/stretchr/testify/mock.Mock$
92+
- ^github.com/testcontainers/testcontainers-go.+Request$
93+
- ^github.com/testcontainers/testcontainers-go.FromDockerfile$
94+
- ^golang.org/x/tools/go/analysis.Analyzer$
95+
- ^google.golang.org/protobuf/.+Options$
96+
- ^gopkg.in/yaml.v3.Node$
97+
funlen:
98+
lines: 100
99+
statements: 50
100+
gocognit:
101+
min-complexity: 20
102+
gocritic:
103+
settings:
104+
captLocal:
105+
paramsOnly: false
106+
underef:
107+
skipRecvDeref: false
108+
gomodguard:
109+
blocked:
110+
modules:
111+
- github.com/golang/protobuf:
112+
recommendations:
113+
- google.golang.org/protobuf
114+
reason: see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules
115+
- github.com/satori/go.uuid:
116+
recommendations:
117+
- github.com/google/uuid
118+
reason: satori's package is not maintained
119+
- github.com/gofrs/uuid:
120+
recommendations:
121+
- github.com/google/uuid
122+
reason: gofrs' package is not go module
123+
govet:
124+
disable:
125+
- fieldalignment
126+
enable-all: true
127+
settings:
128+
shadow:
129+
strict: true
130+
mnd:
131+
ignored-functions:
132+
- os.Chmod
133+
- os.Mkdir
134+
- os.MkdirAll
135+
- os.OpenFile
136+
- os.WriteFile
137+
- prometheus.ExponentialBuckets
138+
- prometheus.ExponentialBucketsRange
139+
- prometheus.LinearBuckets
140+
nakedret:
141+
max-func-lines: 0
142+
nolintlint:
143+
require-explanation: true
144+
require-specific: true
145+
allow-no-explanation:
146+
- funlen
147+
- gocognit
148+
- lll
149+
rowserrcheck:
150+
packages:
151+
- github.com/jmoiron/sqlx
152+
exclusions:
153+
generated: lax
154+
presets:
155+
- comments
156+
- common-false-positives
157+
- legacy
158+
- std-error-handling
159+
rules:
160+
- linters:
161+
- stylecheck
162+
path: command\.go
163+
paths:
164+
- third_party$
165+
- '.*_test\.go$'
166+
- builtin$
167+
- examples$
168+
issues:
169+
max-same-issues: 50
170+
formatters:
171+
enable:
172+
- goimports
173+
exclusions:
174+
generated: lax
175+
paths:
176+
- third_party$
177+
- builtin$
178+
- examples$

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ GOPATH = $(HOME)/go
77
GOBIN = $(GOPATH)/bin
88
GO ?= GOGC=off $(shell which go)
99

10+
GOLANGCI_LINT_VERSION = v2.5.0
11+
1012
# Printing
1113
V = 0
1214
Q = $(if $(filter 1,$V),,@)
@@ -23,7 +25,7 @@ $(BIN)/%: | $(BIN) ; $(info $(M) building $(@F)…)
2325

2426
GOLANGCI_LINT = $(BIN)/golangci-lint
2527
$(BIN)/golangci-lint: | $(BIN) ;
26-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.42.1
28+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/$(GOLANGCI_LINT_VERSION)/install.sh| sh -s $(GOLANGCI_LINT_VERSION)
2729

2830
STRINGER = $(BIN)/stringer
2931
GOIMPORTS = $(BIN)/goimports

command.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func (srv *Server) handleSimpleQuery(ctx context.Context, cn SQLConnection) erro
244244
}
245245
if !headersWritten {
246246
headersWritten = true
247-
srv.writeSQLResultHeader(ctx, res, dw)
247+
srv.writeSQLResultHeader(ctx, res, dw, nil)
248248
}
249249
srv.writeSQLResultRows(ctx, res, dw)
250250
// TODO: add debug messages, configurably
@@ -283,16 +283,16 @@ func (srv *Server) writeSQLResultRows(ctx context.Context, res sqldata.ISQLResul
283283
return nil
284284
}
285285

286-
func (srv *Server) writeSQLResultHeader(ctx context.Context, res sqldata.ISQLResult, writer DataWriter) error {
286+
func (srv *Server) writeSQLResultHeader(ctx context.Context, res sqldata.ISQLResult, writer DataWriter, resultFormats []int16) error {
287287
var colz Columns
288-
for _, c := range res.GetColumns() {
288+
for i, c := range res.GetColumns() {
289289
colz = append(colz,
290290
Column{
291291
Table: c.GetTableId(),
292292
Name: c.GetName(),
293293
Oid: oid.Oid(c.GetObjectID()),
294294
Width: c.GetWidth(),
295-
Format: TextFormat,
295+
Format: resolveResultFormat(resultFormats, i),
296296
},
297297
)
298298
}

docs/aot_metadata.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

docs/developer-guide.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Developer Guide
3+
4+
## Running linter locally
5+
6+
```bash
7+
make lint
8+
```

0 commit comments

Comments
 (0)