Skip to content

Commit

Permalink
Merge pull request #1138 from tigrisdata/main
Browse files Browse the repository at this point in the history
Beta release
  • Loading branch information
efirs authored May 5, 2023
2 parents 1a1b1b0 + 1ffb3f8 commit 5bbd0c3
Show file tree
Hide file tree
Showing 176 changed files with 1,162 additions and 1,104 deletions.
120 changes: 119 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ linters:
- lll
- nlreturn
- nosnakecase
- revive
- stylecheck
- wsl
#- interfacebloat
Expand Down Expand Up @@ -74,3 +73,122 @@ linters-settings:
limitations under the License.
lll:
line-length: 120

forbidigo:
forbid:
- '^errors\.Wrap$'
- '^errors\.Wrapf$'
revive:
enable-all-rules: true
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#add-constant
- name: add-constant
severity: warning
disabled: true
arguments:
- maxLitCount: "3"
allowStrs: '""'
allowInts: "0,1,2"
allowFloats: "0.0,0.,1.0,1.,2.0,2."
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#argument-limit
- name: argument-limit
arguments: [8]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#banned-characters
- name: banned-characters
arguments: ["Ω"]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return
- name: bare-return
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cognitive-complexity
- name: cognitive-complexity
disabled: true
arguments: [22] # default 7
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#comment-spacings
- name: comment-spacings
disabled: true
arguments:
- nolint
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-naming
- name: confusing-naming
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-results
- name: confusing-results
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
- name: context-as-argument
arguments:
- allowTypesBefore: "*testing.T"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cyclomatic
- name: cyclomatic
disabled: true
arguments: [25] # default 3
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer
- name: defer
arguments:
- ["call-chain", "loop"]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported
- name: exported
disabled: true
arguments:
- "checkPrivateReceivers"
- "sayRepetitiveInsteadOfStutters"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#file-header
- name: file-header
disabled: true
arguments:
- This is the text that must appear at the top of source files.
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter
- name: flag-parameter
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit
- name: function-result-limit
arguments: [4] # default 2
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-length
- name: function-length
disabled: true
arguments: [50, 0]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#imports-blacklist
- name: imports-blacklist
arguments:
- "crypto/md5"
- "crypto/sha1"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
- name: import-shadowing
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#line-length-limit
- name: line-length-limit
disabled: true
arguments: [120]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#max-public-structs
- name: max-public-structs
disabled: true
arguments: [3]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#nested-structs
- name: nested-structs
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
- name: string-format
arguments:
- - 'core.WriteError[1].Message'
- '/^([^A-Z]|$)/'
- must not start with a capital letter
- - 'fmt.Errorf[0]'
- '/(^|[^\.!?])$/'
- must not end in punctuation
- - panic
- '/^[^\n]*$/'
- must not contain line breaks
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
- name: struct-tag
arguments:
- "json,inline"
- "bson,outline,gnu"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
- name: var-naming
disabled: true
arguments:
- ["ID", "JSON", "HTTP", "URL", "API"] # AllowList
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
- name: unhandled-error
arguments:
- "fmt.Printf"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ deps:
.PRECIOUS: ${PROTO_DIR}/%_openapi.yaml ${PROTO_DIR}/%.proto

BUILD_PARAM=-tags=release -ldflags "-X 'github.com/tigrisdata/tigris/util.Version=$(VERSION)' -X 'github.com/tigrisdata/tigris/util.BuildHash=$(GIT_HASH)'" $(shell printenv BUILD_PARAM)
TEST_PARAM=-cover -race -tags=test,integration $(shell printenv TEST_PARAM)
TEST_PARAM=-cover -race -tags=test,integration,tigris_http,tigris_grpc $(shell printenv TEST_PARAM)

${PROTO_DIR}/%.proto:
git submodule update --init --recursive
Expand Down
2 changes: 1 addition & 1 deletion api/proto
Submodule proto updated from 466ca6 to 90719c
8 changes: 4 additions & 4 deletions api/server/v1/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (x *SetRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch strings.ToLower(key) {
case "project":
Expand Down Expand Up @@ -69,7 +69,7 @@ func (x *GetSetRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch strings.ToLower(key) {
case "project":
Expand Down Expand Up @@ -104,7 +104,7 @@ func (x *DelRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any
switch strings.ToLower(key) {
case "project":
v = &x.Project
Expand All @@ -131,7 +131,7 @@ func (x *KeysRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any
switch strings.ToLower(key) {
case "project":
v = &x.Project
Expand Down
2 changes: 1 addition & 1 deletion api/server/v1/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func FromStatusError(err error) *TigrisError {

// Errorf constructs TigrisError.
// This is the only error server code should return.
func Errorf(c Code, format string, a ...interface{}) *TigrisError {
func Errorf(c Code, format string, a ...any) *TigrisError {
if c == Code_OK {
return nil
}
Expand Down
32 changes: 16 additions & 16 deletions api/server/v1/marshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type CustomDecoder struct {
reader io.Reader
}

func (f CustomDecoder) Decode(dst interface{}) error {
func (f CustomDecoder) Decode(dst any) error {
if _, ok := dst.(*GetAccessTokenRequest); ok {
byteArr, err := io.ReadAll(f.reader)
if err != nil {
Expand All @@ -53,7 +53,7 @@ type CustomMarshaler struct {
JSONBuiltin *runtime.JSONBuiltin
}

func (c *CustomMarshaler) NewDecoder(r io.Reader) runtime.Decoder {
func (*CustomMarshaler) NewDecoder(r io.Reader) runtime.Decoder {
return CustomDecoder{
jsonDecoder: jsoniter.NewDecoder(r),
reader: r,
Expand All @@ -64,11 +64,11 @@ func (c *CustomMarshaler) NewEncoder(w io.Writer) runtime.Encoder {
return c.JSONBuiltin.NewEncoder(w)
}

func (c *CustomMarshaler) ContentType(v interface{}) string {
func (c *CustomMarshaler) ContentType(v any) string {
return c.JSONBuiltin.ContentType(v)
}

func (c *CustomMarshaler) Marshal(v interface{}) ([]byte, error) {
func (c *CustomMarshaler) Marshal(v any) ([]byte, error) {
switch ty := v.(type) {
case map[string]proto.Message:
// this comes from GRPC-gateway streaming code
Expand Down Expand Up @@ -96,14 +96,14 @@ func (c *CustomMarshaler) Marshal(v interface{}) ([]byte, error) {
return c.JSONBuiltin.Marshal(v)
}

func (c *CustomMarshaler) Unmarshal(data []byte, v interface{}) error {
func (c *CustomMarshaler) Unmarshal(data []byte, v any) error {
if _, ok := v.(*GetAccessTokenRequest); ok {
return unmarshalInternal(data, v)
}
return c.JSONBuiltin.Unmarshal(data, v)
}

func unmarshalInternal(data []byte, v interface{}) error {
func unmarshalInternal(data []byte, v any) error {
if v, ok := v.(*GetAccessTokenRequest); ok {
values, err := url.ParseQuery(string(data))
if err != nil {
Expand Down Expand Up @@ -134,7 +134,7 @@ func (x *ReadRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "project":
Expand Down Expand Up @@ -177,7 +177,7 @@ func (x *SearchRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "project":
Expand Down Expand Up @@ -236,7 +236,7 @@ func (x *ImportRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "primary_key":
Expand Down Expand Up @@ -297,7 +297,7 @@ func (x *InsertRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "project":
Expand Down Expand Up @@ -343,7 +343,7 @@ func (x *ReplaceRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "project":
Expand Down Expand Up @@ -387,7 +387,7 @@ func (x *UpdateRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "project":
Expand Down Expand Up @@ -428,7 +428,7 @@ func (x *DeleteRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "project":
Expand Down Expand Up @@ -465,7 +465,7 @@ func (x *CountRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "project":
Expand Down Expand Up @@ -499,7 +499,7 @@ func (x *CreateOrUpdateCollectionRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "project":
Expand Down Expand Up @@ -536,7 +536,7 @@ func (x *CreateOrUpdateCollectionsRequest) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "project":
Expand Down
2 changes: 1 addition & 1 deletion api/server/v1/realtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (x *Message) UnmarshalJSON(data []byte) error {
}

for key, value := range mp {
var v interface{}
var v any

switch key {
case "id":
Expand Down
Loading

0 comments on commit 5bbd0c3

Please sign in to comment.