Skip to content

Commit b7693d3

Browse files
committed
Fix typos, add golanci-lint check and CI step
1 parent d35b661 commit b7693d3

File tree

7 files changed

+117
-7
lines changed

7 files changed

+117
-7
lines changed

.github/workflows/go.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ jobs:
2020

2121
- name: Test
2222
run: go test -v ./ -race
23+
24+
lint:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: "Run golangci-lint"
28+
uses: golangci/golangci-lint-action@v3

.golangci.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
run:
3+
deadline: 1m
4+
issues-exit-code: 1
5+
tests: true
6+
7+
output:
8+
format: colored-line-number
9+
print-issued-lines: false
10+
11+
linters-settings:
12+
misspell:
13+
locale: US
14+
15+
issues:
16+
exclude-use-default: false
17+
max-issues-per-linter: 0
18+
max-same-issues: 0
19+
exclude-rules:
20+
- linters: revive
21+
text: "^package-comments:"
22+
23+
linters:
24+
disable-all: true
25+
enable:
26+
- asasalint
27+
- asciicheck
28+
- bidichk
29+
- containedctx
30+
- contextcheck
31+
- decorder
32+
- dupl
33+
- dupword
34+
- durationcheck
35+
- errcheck
36+
- errchkjson
37+
- errname
38+
- errorlint
39+
- exhaustive
40+
- exportloopref
41+
- forbidigo
42+
- forcetypeassert
43+
- gochecknoglobals
44+
- gochecknoinits
45+
- goconst
46+
- gocritic
47+
- godot
48+
- godox
49+
- goerr113
50+
- gofmt
51+
- gofumpt
52+
- goimports
53+
- gomnd
54+
- gomoddirectives
55+
- gomodguard
56+
- goprintffuncname
57+
- gosec
58+
- gosimple
59+
- gosmopolitan
60+
- govet
61+
- grouper
62+
- importas
63+
- ineffassign
64+
- interfacebloat
65+
- ireturn
66+
- lll
67+
- loggercheck
68+
- makezero
69+
- mirror
70+
- misspell
71+
- musttag
72+
- nakedret
73+
- nilerr
74+
- nilnil
75+
- noctx
76+
- nolintlint
77+
- nonamedreturns
78+
- nosprintfhostport
79+
- prealloc
80+
- predeclared
81+
- promlinter
82+
- reassign
83+
- revive
84+
- rowserrcheck
85+
- sqlclosecheck
86+
- staticcheck
87+
- tagalign
88+
- tagliatelle
89+
- tenv
90+
- testableexamples
91+
- thelper
92+
- typecheck
93+
- unconvert
94+
- unparam
95+
- unused
96+
- usestdlibvars
97+
- wastedassign
98+
- whitespace
99+
- wrapcheck
100+
- wsl

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
[![Go Reference](https://pkg.go.dev/badge/github.com/bombsimon/jtd-infer-go.svg)](https://pkg.go.dev/github.com/bombsimon/jtd-infer-go)
44
[![Build and test](https://github.com/bombsimon/jtd-infer-go/actions/workflows/go.yaml/badge.svg)](https://github.com/bombsimon/jtd-infer-go/actions/workflows/go.yaml)
55

6-
This is a port of [`json-typedef-infer`][jtd-infer] Go. The reason for porting
7-
this is that I was in need of JTD inference from code and not as a CLI tool.
6+
This is a port of [`json-typedef-infer`][jtd-infer] for Go. The reason for
7+
porting this is that I was in need of JTD inference from code and not as a CLI
8+
tool.
89

910
For more information about JSON Typedef and its RFC and how to use different
10-
kind of hints see [`json-typedef-infer`][jtd-infer]
11+
kind of hints see [`json-typedef-infer`][jtd-infer].
1112

1213
## Usage
1314

hints.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ type Hints struct {
1212
Discriminator HintSet
1313
}
1414

15+
// WithoutHints is a shorthand to return empty hints.
1516
func WithoutHints() Hints {
1617
return Hints{}
1718
}
1819

19-
// SubHint will return the sub hints for all hint sets for the passed key.
20+
// SubHints will return the sub hints for all hint sets for the passed key.
2021
func (h Hints) SubHints(key string) Hints {
2122
return Hints{
2223
DefaultNumType: h.DefaultNumType,
@@ -60,7 +61,7 @@ func (h HintSet) Add(v []string) HintSet {
6061
return h
6162
}
6263

63-
// SubHint will filter all the current sets and keep those who's first element
64+
// SubHints will filter all the current sets and keep those who's first element
6465
// matches the passed key or wildcard.
6566
func (h HintSet) SubHints(key string) HintSet {
6667
filteredValues := [][]string{}

inferred_number.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
// JTD.
1111
type NumType uint8
1212

13+
// Available number types.
1314
const (
1415
NumTypeUint8 NumType = iota
1516
NumTypeInt8
@@ -97,7 +98,7 @@ func (i *InferredNumber) Infer(n float64) *InferredNumber {
9798
}
9899
}
99100

100-
// InfoType will convert an `InferredNumber` to a `jtd.Type`.
101+
// IntoType will convert an `InferredNumber` to a `jtd.Type`.
101102
func (i *InferredNumber) IntoType(defaultType NumType) jtd.Type {
102103
if i.ContainedBy(defaultType) {
103104
return defaultType.IntoType()

inferred_schema.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
// available types for JTD.
1414
type SchemaType int8
1515

16+
// Available schema types.
1617
const (
1718
SchemaTypeUnknown SchemaType = iota
1819
SchemaTypeAny

inferrer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Inferrer struct {
1111
Hints Hints
1212
}
1313

14-
// NewInferred will create a new inferrer with a default `InferredSchema`.
14+
// NewInferrer will create a new inferrer with a default `InferredSchema`.
1515
func NewInferrer(hints Hints) *Inferrer {
1616
return &Inferrer{
1717
Inference: NewInferredSchema(),

0 commit comments

Comments
 (0)