summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-01-27 00:17:49 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-01-29 02:14:51 -0700
commit2824310168b9dbe24c2d47cfb71d4283b1733642 (patch)
treed69110434583a40e5c3e17af3c5559b4918fb22b
parenta74b77265f6249385c38ba801822561872418fdf (diff)
.golangci.yml: Turn on 'stylecheck', fix
-rw-r--r--.golangci.yml5
-rw-r--r--compat/json/compat.go3
-rw-r--r--doc.go8
-rw-r--r--errors.go22
-rw-r--r--misc.go6
5 files changed, 29 insertions, 15 deletions
diff --git a/.golangci.yml b/.golangci.yml
index 1076d1a..866c5a4 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -55,7 +55,6 @@ linters:
- ireturn
- lll
- revive
- - stylecheck
- testpackage
- thelper
- varnamelen
@@ -84,8 +83,12 @@ issues:
- gofumpt
- gosec
- noctx
+ - stylecheck
- path: "borrowed_.*_test\\.go"
linters: [gocritic]
text: "commentFormatting: put a space between `//` and comment text"
+ - path: "internal/"
+ linters: [stylecheck]
+ text: "ST1000" # package doc comment
max-issues-per-linter: 0
max-same-issues: 0
diff --git a/compat/json/compat.go b/compat/json/compat.go
index f6ef2f1..0c9e800 100644
--- a/compat/json/compat.go
+++ b/compat/json/compat.go
@@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later
+// Package json is a wrapper around lowmemjson that is a (mostly)
+// drop-in replacement for the standard library's encoding/json.
package json
import (
@@ -15,6 +17,7 @@ import (
"git.lukeshu.com/go/lowmemjson"
)
+//nolint:stylecheck // ST1021 False positive; these aren't comments on individual types.
type (
Number = json.Number
RawMessage = json.RawMessage
diff --git a/doc.go b/doc.go
new file mode 100644
index 0000000..a234500
--- /dev/null
+++ b/doc.go
@@ -0,0 +1,8 @@
+// Copyright (C) 2023 Luke Shumaker <lukeshu@lukeshu.com>
+//
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+// Package lowmemjson is an alternative to the standard library's
+// encoding/json that has lower memory requirements for large data
+// structures.
+package lowmemjson
diff --git a/errors.go b/errors.go
index 5669d36..d36fc83 100644
--- a/errors.go
+++ b/errors.go
@@ -29,7 +29,7 @@ var ErrParserExceededMaxDepth = internal.ErrParserExceededMaxDepth
// low-level decode errors /////////////////////////////////////////////////////////////////////////
// These will be wrapped in a *DecodeError.
-// A *DecodeReadError is returned from Decode (wrapped in a
+// A DecodeReadError is returned from Decode (wrapped in a
// *DecodeError) if there is an I/O error reading the input.
type DecodeReadError struct {
Err error
@@ -41,7 +41,7 @@ func (e *DecodeReadError) Error() string {
}
func (e *DecodeReadError) Unwrap() error { return e.Err }
-// A *DecodeSyntaxError is returned from Decode (wrapped in a
+// A DecodeSyntaxError is returned from Decode (wrapped in a
// *DecodeError) if there is a syntax error in the input.
type DecodeSyntaxError struct {
Err error
@@ -53,7 +53,7 @@ func (e *DecodeSyntaxError) Error() string {
}
func (e *DecodeSyntaxError) Unwrap() error { return e.Err }
-// A *DecodeTypeError is returned from Decode (wrapped in a
+// A DecodeTypeError is returned from Decode (wrapped in a
// *DecodeError) if the JSON input is not appropriate for the given Go
// type.
//
@@ -88,7 +88,7 @@ var ErrDecodeNonEmptyInterface = errors.New("cannot decode into non-empty interf
// high-level decode errors ////////////////////////////////////////////////////////////////////////
-// A *DecodeArgumentError is returned from Decode if the argument is
+// A DecodeArgumentError is returned from Decode if the argument is
// not a non-nil pointer or is not settable.
//
// Alternatively, a *DecodeArgument error may be found inside of a
@@ -100,7 +100,7 @@ var ErrDecodeNonEmptyInterface = errors.New("cannot decode into non-empty interf
// }
type DecodeArgumentError = json.InvalidUnmarshalError
-// A *DecodeError is returned from Decode for all errors except for
+// A DecodeError is returned from Decode for all errors except for
// *DecodeArgumentError.
//
// A *DecodeError wraps *DecodeSyntaxError for malformed or illegal
@@ -121,7 +121,7 @@ func (e *DecodeError) Unwrap() error { return e.Err }
// encode errors ///////////////////////////////////////////////////////////////////////////////////
-// An *EncodeTypeError is returned by Encode when attempting to encode
+// An EncodeTypeError is returned by Encode when attempting to encode
// an unsupported type.
//
// type EncodeTypeError struct {
@@ -129,8 +129,8 @@ func (e *DecodeError) Unwrap() error { return e.Err }
// }
type EncodeTypeError = json.UnsupportedTypeError
-// An *EncodeValueError is returned by Encode when attempting to
-// encode an unsupported value (such as a datastructure with a cycle).
+// An EncodeValueError is returned by Encode when attempting to encode
+// an unsupported value (such as a datastructure with a cycle).
//
// type UnsupportedValueError struct {
// Value reflect.Value
@@ -138,7 +138,7 @@ type EncodeTypeError = json.UnsupportedTypeError
// }
type EncodeValueError = json.UnsupportedValueError
-// An *EncodeMethodError wraps an error that is returned from an
+// An EncodeMethodError wraps an error that is returned from an
// object's method when encoding that object to JSON.
type EncodeMethodError struct {
Type reflect.Type // The Go type that the method is on
@@ -154,8 +154,8 @@ func (e *EncodeMethodError) Unwrap() error { return e.Err }
// reencode errors /////////////////////////////////////////////////////////////////////////////////
-// A *ReEncodeSyntaxError is returned from ReEncoder's methods if
-// there is a syntax error in the input.
+// A ReEncodeSyntaxError is returned from ReEncoder's methods if there
+// is a syntax error in the input.
type ReEncodeSyntaxError struct {
Err error
Offset int64
diff --git a/misc.go b/misc.go
index c3ce785..fb96b4e 100644
--- a/misc.go
+++ b/misc.go
@@ -44,7 +44,7 @@ func writeRune(w io.Writer, c rune) (int, error) {
// JSON string encoding ////////////////////////////////////////////////////////
-// BackSlashEscapeMode identifies one of the three ways that a
+// BackslashEscapeMode identifies one of the three ways that a
// character may be represented in a JSON string:
//
// - literally (no backslash escaping)
@@ -122,8 +122,8 @@ func EscapeDefault(c rune, wasEscaped BackslashEscapeMode) BackslashEscapeMode {
}
}
-// EscapeDefault is a BackslashEscaper that mimics the default
-// behavior of an encoding/json.Encoder that has had
+// EscapeDefaultNonHTMLSafe is a BackslashEscaper that mimics the
+// default behavior of an encoding/json.Encoder that has had
// SetEscapeHTML(false) called on it.
//
// It is like EscapeJSSafe, but also uses long Unicode `\uXXXX`