From 135dc7b359c5cc3c28c0909d2723404cbb20925c Mon Sep 17 00:00:00 2001
From: Xinwei Xiong <86140903+cubxxw@users.noreply.github.com>
Date: Wed, 12 Jul 2023 20:46:34 +0800
Subject: [PATCH] feat: add scripts (#515)
* feat: add scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* build: Infrastructure, openimv3.0.0
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
* feat: add code (#519)
---------
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
.github/workflows/golangci-link.yml | 2 +-
.golangci.yml | 722 +++++++++++++++++++++++++---
CHANGELOG/CHANGELOG-3.0.md | 83 +---
CHANGELOG/CHANGELOG.md | 8 +
internal/rpc/user/user.go | 3 +-
scripts/githooks/pre-commit | 2 +-
scripts/stop_all.sh | 1 -
7 files changed, 685 insertions(+), 136 deletions(-)
diff --git a/.github/workflows/golangci-link.yml b/.github/workflows/golangci-link.yml
index c5fdd7b1b..f3664c1bc 100644
--- a/.github/workflows/golangci-link.yml
+++ b/.github/workflows/golangci-link.yml
@@ -45,7 +45,7 @@ jobs:
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
# Optional: show only new issues if it's a pull request. The default value is `false`.
- only-new-issues: true
+ # only-new-issues: true
# Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
install-mode: "goinstall"
\ No newline at end of file
diff --git a/.golangci.yml b/.golangci.yml
index 8326afe12..ef7c1f811 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -1,10 +1,27 @@
+# Copyright © 2023 OpenIMSDK open source community. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This file contains all available configuration options
+# with their default values.
+
# options for analysis running
run:
# default concurrency is a available CPU number
concurrency: 4
# timeout for analysis, e.g. 30s, 5m, default is 1m
- timeout: 1m
+ timeout: 5m
# exit code when at least one issue was found, default is 1
issues-exit-code: 1
@@ -12,10 +29,36 @@ run:
# include test files or not, default is true
tests: true
+ # list of build tags, all linters use it. Default is empty list.
+ build-tags:
+ - mytag
+
+ # which dirs to skip: issues from them won't be reported;
+ # can use regexp here: generated.*, regexp is applied on full path;
+ # default value is empty list, but default dirs are skipped independently
+ # from this option's value (see skip-dirs-use-default).
+ # "/" will be replaced by current OS file path separator to properly work
+ # on Windows.
+ skip-dirs:
+ - util
+ - .*~
+ - api/swagger/docs
+ - server/docs
+
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
+ # which files to skip: they will be analyzed, but issues from them
+ # won't be reported. Default value is empty list, but there is
+ # no need to include all autogenerated files, we confidently recognize
+ # autogenerated files. If it's not please let us know.
+ # "/" will be replaced by current OS file path separator to properly work
+ # on Windows.
+ skip-files:
+ - ".*\\.my\\.go$"
+ - _test.go
+
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
@@ -30,6 +73,7 @@ run:
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: true
+
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
@@ -44,9 +88,26 @@ output:
# make issues output unique by line, default is true
uniq-by-line: true
+ # add a prefix to the output file references; default is no prefix
+ path-prefix: ""
+
+ # sorts results by: filepath, line and column
+ sort-results: true
# all available settings of specific linters
linters-settings:
+ bidichk:
+ # The following configurations check for all mentioned invisible unicode
+ # runes. It can be omitted because all runes are enabled by default.
+ left-to-right-embedding: true
+ right-to-left-embedding: true
+ pop-directional-formatting: true
+ left-to-right-override: true
+ right-to-left-override: true
+ left-to-right-isolate: true
+ right-to-left-isolate: true
+ first-strong-isolate: true
+ pop-directional-isolate: true
dogsled:
# checks assignments with too many blank identifiers; default is 2
max-blank-identifiers: 2
@@ -62,47 +123,217 @@ linters-settings:
# default is false: such cases aren't reported by default.
check-blank: false
+ # [deprecated] comma-separated list of pairs of the form pkg:regex
+ # the regex is used to ignore names within pkg. (default "fmt:.*").
+ # see https://github.com/kisielk/errcheck#the-deprecated-method for details
+ #ignore: GenMarkdownTree,os:.*,BindPFlags,WriteTo,Help
+ #ignore: (os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv
+
# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
#exclude: errcheck.txt
+
+ errorlint:
+ # Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats
+ errorf: true
+ # Check for plain type assertions and type switches
+ asserts: true
+ # Check for plain error comparisons
+ comparison: true
+
exhaustive:
+ # check switch statements in generated files also
+ check-generated: false
# indicates that switch statements are to be considered exhaustive if a
# 'default' case is present, even if all enum members aren't listed in the
# switch
default-signifies-exhaustive: false
+ # enum members matching the supplied regex do not have to be listed in
+ # switch statements to satisfy exhaustiveness
+ ignore-enum-members: ""
+ # consider enums only in package scopes, not in inner scopes
+ package-scope-only: false
+ exhaustivestruct:
+ struct-patterns:
+ - '*.Test'
+ - '*.Test2'
+ - '*.Embedded'
+ - '*.External'
+
+ # forbidigo:
+ # # Forbid the following identifiers (identifiers are written using regexp):
+ # forbid:
+ # - ^print.*$
+ # - 'fmt\.Print.*'
+ # - fmt.Println.* # too much log noise
+ # - ginkgo\\.F.* # these are used just for local development
+ # # Exclude godoc examples from forbidigo checks. Default is true.
+ # exclude_godoc_examples: false
funlen:
lines: 150
- statements: 40
+ statements: 50
+ gci:
+ # put imports beginning with prefix after 3rd-party packages;
+ # only support one prefix
+ # if not set, use goimports.local-prefixes
+ prefix: github.com/OpenIMSDK/OpenKF
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 30
- nestif:
- # minimal complexity of if statements to report, 5 by default
- min-complexity: 4
goconst:
# minimal length of string constant, 3 by default
- min-len: 5
+ min-len: 3
# minimal occurrences count to trigger, 3 by default
- min-occurrences: 5
+ min-occurrences: 3
+ # ignore test files, false by default
+ ignore-tests: false
+ # look for existing constants matching the values, true by default
+ match-constant: true
+ # search also for duplicated numbers, false by default
+ numbers: false
+ # minimum value, only works with goconst.numbers, 3 by default
+ min: 3
+ # maximum value, only works with goconst.numbers, 3 by default
+ max: 3
+ # ignore when constant is not used as function argument, true by default
+ ignore-calls: true
+
+ gocritic:
+ # Which checks should be enabled; can't be combined with 'disabled-checks';
+ # See https://go-critic.github.io/overview#checks-overview
+ # To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
+ # By default list of stable checks is used.
+ enabled-checks:
+ #- rangeValCopy
+ - nestingreduce
+ - truncatecmp
+ - unnamedresult
+ - ruleguard
+
+ # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
+ disabled-checks:
+ - regexpMust
+ - ifElseChain
+ #- exitAfterDefer
+
+ # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
+ # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
+ enabled-tags:
+ - performance
+ disabled-tags:
+ - experimental
+
+ # Settings passed to gocritic.
+ # The settings key is the name of a supported gocritic checker.
+ # The list of supported checkers can be find in https://go-critic.github.io/overview.
+ settings:
+ captLocal: # must be valid enabled check name
+ # whether to restrict checker to params only (default true)
+ paramsOnly: true
+ elseif:
+ # whether to skip balanced if-else pairs (default true)
+ skipBalanced: true
+ hugeParam:
+ # size in bytes that makes the warning trigger (default 80)
+ sizeThreshold: 80
+ nestingReduce:
+ # min number of statements inside a branch to trigger a warning (default 5)
+ bodyWidth: 5
+ rangeExprCopy:
+ # size in bytes that makes the warning trigger (default 512)
+ sizeThreshold: 512
+ # whether to check test functions (default true)
+ skipTestFuncs: true
+ rangeValCopy:
+ # size in bytes that makes the warning trigger (default 128)
+ sizeThreshold: 32
+ # whether to check test functions (default true)
+ skipTestFuncs: true
+ ruleguard:
+ # path to a gorules file for the ruleguard checker
+ rules: ''
+ truncateCmp:
+ # whether to skip int/uint/uintptr types (default true)
+ skipArchDependent: true
+ underef:
+ # whether to skip (*x).method() calls where x is a pointer receiver (default true)
+ skipRecvDeref: true
+ unnamedResult:
+ # whether to check exported functions
+ checkExported: true
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 30
+ cyclop:
+ # the maximal code complexity to report
+ max-complexity: 50
+ # the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0)
+ package-average: 0.0
+ # should ignore tests (default false)
+ skip-tests: false
godot:
- # check all top-level comments, not only declarations
- check-all: false
+ # comments to be checked: `declarations`, `toplevel`, or `all`
+ scope: declarations
+ # list of regexps for excluding particular comment lines from check
+ exclude:
+ # example: exclude comments which contain numbers
+ # - '[0-9]+'
+ # check that each sentence starts with a capital letter
+ capital: false
godox:
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
# might be left in the code accidentally and should be resolved before merging
keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting
+ #- TODO
+ - BUG
+ - FIXME
+ #- NOTE
- OPTIMIZE # marks code that should be optimized before merging
- HACK # marks hack-arounds that should be removed before merging
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
+
+ gofumpt:
+ # Select the Go version to target. The default is `1.18`.
+ lang-version: "1.20"
+
+ # Choose whether or not to use the extra rules that are disabled
+ # by default
+ extra-rules: false
+
+ goheader:
+ values:
+ const:
+ # define here const type values in format k:v, for example:
+ # COMPANY: MY COMPANY
+ regexp:
+ # define here regexp type values, for example
+ # AUTHOR: .*@mycompany\.com
+ template: # |-
+ # put here copyright header template for source code files, for example:
+ # Note: {{ YEAR }} is a builtin value that returns the year relative to the current machine time.
+ #
+ # {{ AUTHOR }} {{ COMPANY }} {{ YEAR }}
+ # SPDX-License-Identifier: Apache-2.0
+
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at:
+
+ # http://www.apache.org/licenses/LICENSE-2.0
+
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ template-path:
+ # also as alternative of directive 'template' you may put the path to file with the template source
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
- local-prefixes: github.com/org/project
+ local-prefixes: github.com/OpenIMSDK/OpenKF
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.9
@@ -111,16 +342,91 @@ linters-settings:
mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks: argument,case,condition,operation,return,assign
+ # ignored-numbers: 1000
+ # ignored-files: magic_.*.go
+ # ignored-functions: math.*
+ gomoddirectives:
+ # Allow local `replace` directives. Default is false.
+ replace-local: true
+ # List of allowed `replace` directives. Default is empty.
+ replace-allow-list:
+ - google.golang.org/grpc
+
+ # Allow to not explain why the version has been retracted in the `retract` directives. Default is false.
+ retract-allow-no-explanation: false
+ # Forbid the use of the `exclude` directives. Default is false.
+ exclude-forbidden: false
gomodguard:
allowed:
- modules: # List of allowed modules
+ modules:
+ - gorm.io/gen # List of allowed modules
+ - gorm.io/gorm
+ - gorm.io/driver/mysql
+ - k8s.io/klog
# - gopkg.in/yaml.v2
domains: # List of allowed module domains
- # - golang.org
+ - google.golang.org
+ - gopkg.in
+ - golang.org
+ - github.com
+ - go.uber.org
+ - go.etcd.io
+ blocked:
+ versions:
+ - github.com/MakeNowJust/heredoc:
+ version: "> 2.0.9"
+ reason: "use the latest version"
+ local_replace_directives: false # Set to true to raise lint issues for packages that are loaded from a local path via replace directive
+
+ gosec:
+ # To select a subset of rules to run.
+ # Available rules: https://github.com/securego/gosec#available-rules
+ includes:
+ - G401
+ - G306
+ - G101
+ # To specify a set of rules to explicitly exclude.
+ # Available rules: https://github.com/securego/gosec#available-rules
+ excludes:
+ - G204
+ # Exclude generated files
+ exclude-generated: true
+ # Filter out the issues with a lower severity than the given value. Valid options are: low, medium, high.
+ severity: "low"
+ # Filter out the issues with a lower confidence than the given value. Valid options are: low, medium, high.
+ confidence: "low"
+ # To specify the configuration of rules.
+ # The configuration of rules is not fully documented by gosec:
+ # https://github.com/securego/gosec#configuration
+ # https://github.com/securego/gosec/blob/569328eade2ccbad4ce2d0f21ee158ab5356a5cf/rules/rulelist.go#L60-L102
+ config:
+ G306: "0600"
+ G101:
+ pattern: "(?i)example"
+ ignore_entropy: false
+ entropy_threshold: "80.0"
+ per_char_threshold: "3.0"
+ truncate: "32"
+
+ gosimple:
+ # Select the Go version to target. The default is '1.13'.
+ go: "1.20"
+ # https://staticcheck.io/docs/options#checks
+ checks: [ "all" ]
+
govet:
# report about shadowed variables
check-shadowing: true
+ # settings per analyzer
+ settings:
+ printf: # analyzer name, run `go tool vet help` to see all analyzers
+ funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
+ - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
+ - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
+ - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
+ - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
+
# enable or disable analyzers by name
enable:
- atomicalign
@@ -128,17 +434,69 @@ linters-settings:
disable:
- shadow
disable-all: false
- depguard:
- list-type: blacklist
- include-go-root: false
- packages:
- packages-with-error-message:
+ # depguard:
+ # list-type: blacklist
+ # include-go-root: false
+ # packages:
+ # - github.com/Sirupsen/logrus
+ # packages-with-error-message:
+ # # specify an error message to output when a blacklisted package is used
+ # - github.com/Sirupsen/logrus: "logging is allowed only by logutils.Log"
+ ifshort:
+ # Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
+ # Has higher priority than max-decl-chars.
+ max-decl-lines: 1
+ # Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
+ max-decl-chars: 30
+
+ importas:
+ # if set to `true`, force to use alias.
+ no-unaliased: true
+ # List of aliases
+ alias:
+ # using `servingv1` alias for `knative.dev/serving/pkg/apis/serving/v1` package
+ - pkg: knative.dev/serving/pkg/apis/serving/v1
+ alias: servingv1
+ # using `autoscalingv1alpha1` alias for `knative.dev/serving/pkg/apis/autoscaling/v1alpha1` package
+ - pkg: knative.dev/serving/pkg/apis/autoscaling/v1alpha1
+ alias: autoscalingv1alpha1
+ # You can specify the package path by regular expression,
+ # and alias by regular expression expansion syntax like below.
+ # see https://github.com/julz/importas#use-regular-expression for details
+ - pkg: knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+)
+ alias: $1$2
+ # using `jwt` alias for `github.com/appleboy/gin-jwt/v2` package
+ jwt: github.com/appleboy/gin-jwt/v2
+
+ ireturn:
+ # ireturn allows using `allow` and `reject` settings at the same time.
+ # Both settings are lists of the keywords and regular expressions matched to interface or package names.
+ # keywords:
+ # - `empty` for `interface{}`
+ # - `error` for errors
+ # - `stdlib` for standard library
+ # - `anon` for anonymous interfaces
+
+ # By default, it allows using errors, empty interfaces, anonymous interfaces,
+ # and interfaces provided by the standard library.
+ allow:
+ - anon
+ - error
+ - empty
+ - stdlib
+ # You can specify idiomatic endings for interface
+ - (or|er)$
+
+ # Reject patterns
+ reject:
+ - github.com\/user\/package\/v4\.Type
+
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
- line-length: 120
+ line-length: 240
# tab width in spaces. Default to 1.
- tab-width: 1
+ tab-width: 4
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
@@ -152,26 +510,137 @@ linters-settings:
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 30
- prealloc:
- # XXX: we don't recommend using this linter before doing performance profiling.
- # For most programs usage of prealloc will be a premature optimization.
- # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
- # True by default.
- simple: true
- range-loops: true # Report preallocation suggestions on range loops, true by default
- for-loops: false # Report preallocation suggestions on for loops, false by default
+ nestif:
+ # minimal complexity of if statements to report, 5 by default
+ min-complexity: 4
+
+ nilnil:
+ # By default, nilnil checks all returned types below.
+ checked-types:
+ - ptr
+ - func
+ - iface
+ - map
+ - chan
+
+ nlreturn:
+ # size of the block (including return statement that is still "OK")
+ # so no return split required.
+ block-size: 1
+
nolintlint:
- # Enable to ensure that nolint directives are all used. Default is true.
+ # Disable to ensure that all nolint directives actually have an effect. Default is true.
allow-unused: false
# Disable to ensure that nolint directives don't have a leading space. Default is true.
allow-leading-space: true
# Exclude following linters from requiring an explanation. Default is [].
- allow-no-explanation: []
+ allow-no-explanation: [ ]
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
- require-explanation: true
+ require-explanation: false
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
require-specific: true
+
+ prealloc:
+ # XXX: we don't recommend using this linter before doing performance profiling.
+ # For most programs usage of prealloc will be a premature optimization.
+
+ # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
+ # True by default.
+ simple: true
+ range-loops: true # Report preallocation suggestions on range loops, true by default
+ for-loops: false # Report preallocation suggestions on for loops, false by default
+
+ promlinter:
+ # Promlinter cannot infer all metrics name in static analysis.
+ # Enable strict mode will also include the errors caused by failing to parse the args.
+ strict: false
+ # Please refer to https://github.com/yeya24/promlinter#usage for detailed usage.
+ disabled-linters:
+ # - "Help"
+ # - "MetricUnits"
+ # - "Counter"
+ # - "HistogramSummaryReserved"
+ # - "MetricTypeInName"
+ # - "ReservedChars"
+ # - "CamelCase"
+ # - "lintUnitAbbreviations"
+
+ predeclared:
+ # comma-separated list of predeclared identifiers to not report on
+ ignore: ""
+ # include method names and field names (i.e., qualified names) in checks
+ q: false
+ rowserrcheck:
+ packages:
+ - github.com/jmoiron/sqlx
+ revive:
+ # see https://github.com/mgechev/revive#available-rules for details.
+ ignore-generated-header: true
+ severity: warning
+ rules:
+ - name: indent-error-flow
+ severity: warning
+ staticcheck:
+ # Select the Go version to target. The default is '1.13'.
+ go: "1.16"
+ # https://staticcheck.io/docs/options#checks
+ checks: [ "all" ]
+
+ stylecheck:
+ # Select the Go version to target. The default is '1.13'.
+ go: "1.16"
+
+ # https://staticcheck.io/docs/options#checks
+ checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ]
+ # https://staticcheck.io/docs/options#dot_import_whitelist
+ dot-import-whitelist:
+ - fmt
+ # https://staticcheck.io/docs/options#initialisms
+ initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS" ]
+ # https://staticcheck.io/docs/options#http_status_code_whitelist
+ http-status-code-whitelist: [ "200", "400", "404", "500" ]
+
+
+ tagliatelle:
+ # check the struck tag name case
+ case:
+ # use the struct field name to check the name of the struct tag
+ use-field-name: true
+ rules:
+ # any struct tag type can be used.
+ # support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`
+ json: camel
+ yaml: camel
+ xml: camel
+ bson: camel
+ avro: snake
+ mapstructure: kebab
+
+ testpackage:
+ # regexp pattern to skip files
+ skip-regexp: (id|export|internal)_test\.go
+ thelper:
+ # The following configurations enable all checks. It can be omitted because all checks are enabled by default.
+ # You can enable only required checks deleting unnecessary checks.
+ test:
+ first: true
+ name: true
+ begin: true
+ benchmark:
+ first: true
+ name: true
+ begin: true
+ tb:
+ first: true
+ name: true
+ begin: true
+
+ tenv:
+ # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
+ # By default, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
+ all: false
+
unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
@@ -187,6 +656,24 @@ linters-settings:
whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
+
+ wrapcheck:
+ # An array of strings that specify substrings of signatures to ignore.
+ # If this set, it will override the default set of ignored signatures.
+ # See https://github.com/tomarrell/wrapcheck#configuration for more information.
+ ignoreSigs:
+ - .Errorf(
+ - errors.New(
+ - errors.Unwrap(
+ - .Wrap(
+ - .Wrapf(
+ - .WithMessage(
+ - .WithMessagef(
+ - .WithStack(
+ ignorePackageGlobs:
+ - encoding/*
+ - github.com/pkg/*
+
wsl:
# If true append is only allowed to be cuddled if appending value is
# matching variables, fields or types on line above. Default is true.
@@ -194,6 +681,8 @@ linters-settings:
# Allow calls and assignments to be cuddled as long as the lines have any
# matching variables, fields or types. Default is true.
allow-assign-and-call: true
+ # Allow assignments to be cuddled with anything. Default is false.
+ allow-assign-and-anything: false
# Allow multiline assignments to be cuddled. Default is true.
allow-multiline-assign: true
# Allow declarations (var) to be cuddled.
@@ -206,65 +695,181 @@ linters-settings:
force-err-cuddling: false
# Allow leading comments to be separated with empty liens
allow-separated-leading-comment: false
+ makezero:
+ # Allow only slices initialized with a length of zero. Default is false.
+ always: false
+
+
+ # The custom section can be used to define linter plugins to be loaded at runtime. See README doc
+ # for more info.
+ #custom:
+ # Each custom linter should have a unique name.
+ #example:
+ # The path to the plugin *.so. Can be absolute or local. Required for each custom linter
+ #path: /path/to/example.so
+ # The description of the linter. Optional, just for documentation purposes.
+ #description: This is an example usage of a plugin linter.
+ # Intended to point to the repo location of the linter. Optional, just for documentation purposes.
+ #original-url: github.com/golangci/example-linter
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
+ # enable-all: true
disable-all: true
enable:
+ - typecheck
+ - asciicheck
- bodyclose
+ - cyclop
- deadcode
- - depguard
+ # - depguard
- dogsled
- dupl
+ - durationcheck
- errcheck
+ - errorlint
+ - exhaustive
+ - exportloopref
+ # - forbidigo
- funlen
- - gochecknoinits
+ # - gci
+ # - gochecknoinits
+ - gocognit
- goconst
- - gocritic
- gocyclo
+ - godot
+ - godox
- gofmt
+ - gofumpt
+ - goheader
- goimports
- - golint
+ - gomoddirectives
+ - gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
+ - ifshort
+ - importas
- ineffassign
- - interfacer
- lll
+ - makezero
- misspell
- nakedret
+ - nestif
+ - nilerr
+ - nlreturn
+ - noctx
- nolintlint
+ - paralleltest
+ - prealloc
+ - predeclared
+ - promlinter
+ - revive
- rowserrcheck
- - scopelint
+ - sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- - typecheck
+ - thelper
+ - tparallel
- unconvert
- unparam
- unused
- varcheck
+ - wastedassign
- whitespace
- - asciicheck
- - gocognit
- - godot
- - godox
- - maligned
- - nestif
- - prealloc
- - gomodguard
- # don't enable:
- #- goerr113
- #- wsl
- #- testpackage
- #- exhaustive (TODO: enable after next release; current release at time of writing is v1.27)
- #- gochecknoglobals
- #- gomnd
+ - bidichk
+ - wastedassign
+ - golint
+ - execinquery
+ - nosprintfhostport
+ - grouper
+ - decorder
+ - errchkjson
+ - maintidx
+ #- containedctx
+ #- tagliatelle
+ #- nonamedreturns
+ #- nilnil
+ #- tenv
+ #- varnamelen
+ #- contextcheck
+ #- errname
+ #- ForceTypeAssert
+ #- nilassign
+ fast: false
issues:
+ # List of regexps of issue texts to exclude, empty list by default.
+ # But independently from this option we use default exclude patterns,
+ # it can be disabled by `exclude-use-default: false`. To list all
+ # excluded by default patterns execute `golangci-lint run --help`
+ exclude:
+ - tools/.*
+ - test/.*
+ - third_party/.*
+
# Excluding configuration per-path, per-linter, per-text and per-source
+ exclude-rules:
+ - linters:
+ - golint
+ path: (internal/api/.*)\.go # exclude golint for internal/api/... files
+
+ - linters:
+ - revive
+ path: (log/.*)\.go
+
+ - linters:
+ - wrapcheck
+ path: (cmd/.*|pkg/.*)\.go
+
+ - linters:
+ - typecheck
+ #path: (pkg/storage/.*)\.go
+ path: (internal/.*|pkg/.*)\.go
+
+ - path: (cmd/.*|test/.*|tools/.*|internal/pump/pumps/.*)\.go
+ linters:
+ - forbidigo
+
+ - path: (cmd/[a-z]*/.*|store/.*)\.go
+ linters:
+ - dupl
+
+ - linters:
+ - gocritic
+ text: (hugeParam:|rangeValCopy:)
+
+ - path: (cmd/[a-z]*/.*)\.go
+ linters:
+ - lll
+
+ - path: (validator/.*|code/.*|validator/.*|watcher/watcher/.*)
+ linters:
+ - gochecknoinits
+
+ - path: (internal/.*/options|internal/pump|pkg/log/options.go|internal/authzserver|tools/)
+ linters:
+ - tagliatelle
+
+ - path: (pkg/app/.*)\.go
+ linters:
+ - deadcode
+ - unused
+ - varcheck
+ - forbidigo
+
+ # Exclude some staticcheck messages
+ - linters:
+ - staticcheck
+ text: "SA9003:"
+
+ # Exclude lll issues for long lines with go:generate
+ - linters:
+ - lll
+ source: "^//go:generate "
# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
@@ -300,24 +905,27 @@ issues:
# Show only new issues created in git patch with set file path.
#new-from-patch: path/to/patch/file
+ # Fix found issues (if it's supported by the linter)
+ fix: true
+
severity:
# Default value is empty string.
- # Set the default severity for issues. If severity rules are defined and the issues
- # do not match or no severity is provided to the rule this will be the default
- # severity applied. Severities should match the supported severity names of the
+ # Set the default severity for issues. If severity rules are defined and the issues
+ # do not match or no severity is provided to the rule this will be the default
+ # severity applied. Severities should match the supported severity names of the
# selected out format.
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity
# - Github: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
default-severity: error
- # The default value is false.
+ # The default value is false.
# If set to true severity-rules regular expressions become case sensitive.
case-sensitive: false
# Default value is empty list.
# When a list of severity rules are provided, severity information will be added to lint
- # issues. Severity rules have the same filtering capability as exclude rules except you
+ # issues. Severity rules have the same filtering capability as exclude rules except you
# are allowed to specify one matcher per severity rule.
# Only affects out formats that support setting severity information.
rules:
diff --git a/CHANGELOG/CHANGELOG-3.0.md b/CHANGELOG/CHANGELOG-3.0.md
index 72cc56bbf..cf1aa4b62 100644
--- a/CHANGELOG/CHANGELOG-3.0.md
+++ b/CHANGELOG/CHANGELOG-3.0.md
@@ -1,23 +1,9 @@
# Version logging for OpenIM
-**3.0 Major refactoring**
-
-
- [Version logging for OpenIM](#version-logging-for-openim)
- - [\[v3.0\]](#v30)
- - [v3.0.0 - 2023-07-10](#v300---2023-07-10)
- - [v2.9.0+1.839643f - 2023-07-07](#v2901839643f---2023-07-07)
- - [v2.9.0+2.35f07fe - 2023-07-06](#v290235f07fe---2023-07-06)
- - [v2.9.0+1.b5072b1 - 2023-07-05](#v2901b5072b1---2023-07-05)
- - [v2.9.0+3.2667a3a - 2023-07-05](#v29032667a3a---2023-07-05)
- - [v2.9.0+7.04818ca - 2023-07-05](#v290704818ca---2023-07-05)
+ - [Unreleased](#unreleased)
- [v2.9.0 - 2023-07-04](#v290---2023-07-04)
- - [v0.0.0+1.3714b4f - 2023-07-04](#v00013714b4f---2023-07-04)
- - [v0.0.0+635.8b92c90 - 2023-07-04](#v0006358b92c90---2023-07-04)
- - [v0.0.0+1.78a6d03 - 2023-07-04](#v000178a6d03---2023-07-04)
- - [v0.0.0+2.e057c18 - 2023-07-04](#v0002e057c18---2023-07-04)
- - [v0.0.0+630.b55ac4a - 2023-07-04](#v000630b55ac4a---2023-07-04)
- [Reverts](#reverts)
- [Pull Requests](#pull-requests)
- [v2.3.3 - 2022-09-18](#v233---2022-09-18)
@@ -32,17 +18,15 @@
- [v2.0.9 - 2022-04-29](#v209---2022-04-29)
- [Reverts](#reverts-1)
- [Pull Requests](#pull-requests-2)
- - [v2.0.8 - 2022-04-24](#v208---2022-04-24)
- - [Pull Requests](#pull-requests-3)
- [v2.0.7 - 2022-04-08](#v207---2022-04-08)
- - [Pull Requests](#pull-requests-4)
+ - [Pull Requests](#pull-requests-3)
- [v2.0.6 - 2022-04-01](#v206---2022-04-01)
- - [Pull Requests](#pull-requests-5)
+ - [Pull Requests](#pull-requests-4)
- [v2.0.5 - 2022-03-24](#v205---2022-03-24)
- [v2.04 - 2022-03-18](#v204---2022-03-18)
- [v2.0.3 - 2022-03-11](#v203---2022-03-11)
- [v2.0.2 - 2022-03-04](#v202---2022-03-04)
- - [Pull Requests](#pull-requests-6)
+ - [Pull Requests](#pull-requests-5)
- [v2.0.1 - 2022-02-25](#v201---2022-02-25)
- [v2.0.0 - 2022-02-23](#v200---2022-02-23)
- [v1.0.7 - 2021-12-17](#v107---2021-12-17)
@@ -54,48 +38,14 @@
- [v1.0.0 - 2021-10-28](#v100---2021-10-28)
- [Reverts](#reverts-2)
-
-## [v3.0]
-
-
-
-## [v3.0.0] - 2023-07-10
-
-
-## [v2.9.0+1.839643f] - 2023-07-07
+## [Unreleased]
-
-## [v2.9.0+2.35f07fe] - 2023-07-06
-
-
-## [v2.9.0+1.b5072b1] - 2023-07-05
-
-
-## [v2.9.0+3.2667a3a] - 2023-07-05
-
-
-## [v2.9.0+7.04818ca] - 2023-07-05
## [v2.9.0] - 2023-07-04
-
-
-## [v0.0.0+1.3714b4f] - 2023-07-04
-
-
-## [v0.0.0+635.8b92c90] - 2023-07-04
-
-
-## [v0.0.0+1.78a6d03] - 2023-07-04
-
-
-## [v0.0.0+2.e057c18] - 2023-07-04
-
-
-## [v0.0.0+630.b55ac4a] - 2023-07-04
### Reverts
- update etcd to v3.5.2 ([#206](https://github.com/OpenIMSDK/Open-IM-Server/issues/206))
@@ -144,11 +94,6 @@
- Merge branch 'tuoyun'
- Merge branch 'tuoyun'
- Merge branch 'tuoyun'
-
-
-
-## [v2.0.8] - 2022-04-24
-### Pull Requests
- Merge branch 'tuoyun'
- Merge branch 'tuoyun'
@@ -216,19 +161,8 @@
- update
-[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v3.0.0...HEAD
-[v3.0.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+1.839643f...v3.0.0
-[v2.9.0+1.839643f]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+2.35f07fe...v2.9.0+1.839643f
-[v2.9.0+2.35f07fe]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+1.b5072b1...v2.9.0+2.35f07fe
-[v2.9.0+1.b5072b1]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+3.2667a3a...v2.9.0+1.b5072b1
-[v2.9.0+3.2667a3a]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0+7.04818ca...v2.9.0+3.2667a3a
-[v2.9.0+7.04818ca]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0...v2.9.0+7.04818ca
-[v2.9.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v0.0.0+1.3714b4f...v2.9.0
-[v0.0.0+1.3714b4f]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v0.0.0+635.8b92c90...v0.0.0+1.3714b4f
-[v0.0.0+635.8b92c90]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v0.0.0+1.78a6d03...v0.0.0+635.8b92c90
-[v0.0.0+1.78a6d03]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v0.0.0+2.e057c18...v0.0.0+1.78a6d03
-[v0.0.0+2.e057c18]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v0.0.0+630.b55ac4a...v0.0.0+2.e057c18
-[v0.0.0+630.b55ac4a]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.3...v0.0.0+630.b55ac4a
+[Unreleased]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.9.0...HEAD
+[v2.9.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.3...v2.9.0
[v2.3.3]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.2...v2.3.3
[v2.3.2]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc2...v2.3.2
[v2.3.0-rc2]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.3.0-rc1...v2.3.0-rc2
@@ -237,8 +171,7 @@
[v2.2.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.1.0...v2.2.0
[v2.1.0]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.10...v2.1.0
[v2.0.10]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.9...v2.0.10
-[v2.0.9]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.8...v2.0.9
-[v2.0.8]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.7...v2.0.8
+[v2.0.9]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.7...v2.0.9
[v2.0.7]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.6...v2.0.7
[v2.0.6]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.0.5...v2.0.6
[v2.0.5]: https://github.com/OpenIMSDK/Open-IM-Server/compare/v2.04...v2.0.5
diff --git a/CHANGELOG/CHANGELOG.md b/CHANGELOG/CHANGELOG.md
index 39ed572db..3307c2068 100644
--- a/CHANGELOG/CHANGELOG.md
+++ b/CHANGELOG/CHANGELOG.md
@@ -18,6 +18,14 @@ git commit -am "release 2.0.0"
git tag 2.0.0
```
+| Query | Description | Example |
+| -------------- | ---------------------------------------------- | --------------------------- |
+| `..` | Commit contained in `` tags from ``. | `$ git-chglog 1.0.0..2.0.0` |
+| `..` | Commit from the `` to the latest tag. | `$ git-chglog 1.0.0..` |
+| `..` | Commit from the oldest tag to ``. | `$ git-chglog ..2.0.0` |
+| `` | Commit contained in ``. | `$ git-chglog 1.0.0` |
+
+
## Release version logs
+ [OpenIM CHANGELOG-V1.0](CHANGELOG-1.0.md)
diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go
index 4619db4ce..0914e9d1d 100644
--- a/internal/rpc/user/user.go
+++ b/internal/rpc/user/user.go
@@ -3,10 +3,11 @@ package user
import (
"context"
"errors"
- "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"strings"
"time"
+ "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
+
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit
index 8fbee166c..c14d1a967 100644
--- a/scripts/githooks/pre-commit
+++ b/scripts/githooks/pre-commit
@@ -26,7 +26,7 @@
LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
-valid_branch_regex="^(main|master|develop)$|(feature|feat|openim|release|hotfix|test|bug|ci|cicd|style|)\/[a-z0-9._-]+$|^HEAD$"
+valid_branch_regex="^(main|master|develop|release)$|(feature|feat|openim|hotfix|test|bug|ci|cicd|style|)\/[a-z0-9._-]+$|^HEAD$"
YELLOW="\e[93m"
GREEN="\e[32m"
diff --git a/scripts/stop_all.sh b/scripts/stop_all.sh
index f413d2a66..8bd5aaf34 100755
--- a/scripts/stop_all.sh
+++ b/scripts/stop_all.sh
@@ -20,7 +20,6 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
#Include shell font styles and some basic information
source $OPENIM_ROOT/scripts/style_info.sh
source $OPENIM_ROOT/scripts/path_info.sh
-source $OPENIM_ROOT/scripts/function.sh
bin_dir="$BIN_DIR"
logs_dir="$OPENIM_ROOT/logs"