Merge remote-tracking branch 'origin/3.6.1-code-conventions' into 3.6.1-code-conventions

pull/2100/head
Gordon 2 years ago
commit f16479380d

@ -56,7 +56,8 @@ jobs:
- name: Generate all necessary files, such as error code files
run: |
make generate
make gen.docgo.doc
make gen
echo "Generate all necessary files successfully"
continue-on-error: true

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -0,0 +1,15 @@
// Copyright © 2024 OpenIM. 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.
package cachekey // import "github.com/openimsdk/open-im-server/v3/pkg/common/cachekey"

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -0,0 +1,15 @@
// Copyright © 2024 OpenIM. 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.
package mgo // import "github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo"

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package cos // import "internal/pkg/pkg/common/db/s3/cos"
package cos // import "github.com/openimsdk/open-im-server/v3/pkg/common/db/s3/cos"

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package minio // import "internal/pkg/pkg/common/db/s3/minio"
package minio // import "github.com/openimsdk/open-im-server/v3/pkg/common/db/s3/minio"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package oss // import "internal/pkg/pkg/common/db/s3/oss"
package oss // import "github.com/openimsdk/open-im-server/v3/pkg/common/db/s3/oss"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package relation // import "internal/pkg/pkg/common/db/table/relation"
package relation // import "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package direct // import "internal/pkg/pkg/common/discoveryregister/direct"
package direct // import "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/direct"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package discoveryregister // import "internal/pkg/pkg/common/discoveryregister"
package discoveryregister // import "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package kubernetes // import "internal/pkg/pkg/common/discoveryregister/kubernetes"
package kubernetes // import "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/kubernetes"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package zookeeper // import "internal/pkg/pkg/common/discoveryregister/zookeeper"
package zookeeper // import "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/zookeeper"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package ginprometheus // import "internal/pkg/pkg/common/ginprometheus"
package ginprometheus // import "github.com/openimsdk/open-im-server/v3/pkg/common/ginprometheus"

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package prommetrics // import "internal/pkg/pkg/common/prommetrics"
package prommetrics // import "github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package redispubsub // import "internal/pkg/pkg/common/redispubsub"
package redispubsub // import "github.com/openimsdk/open-im-server/v3/pkg/common/redispubsub"

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.
@ -12,5 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// Package startrpc start rpc server.
package startrpc
package startrpc // import "github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package tls // import "internal/pkg/pkg/common/tls"
package tls // import "github.com/openimsdk/open-im-server/v3/pkg/common/tls"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package version // import "internal/pkg/pkg/common/version"
package version // import "github.com/openimsdk/open-im-server/v3/pkg/common/version"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package localcache // import "internal/pkg/pkg/localcache"
package localcache // import "github.com/openimsdk/open-im-server/v3/pkg/localcache"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package link // import "internal/pkg/pkg/localcache/link"
package link // import "github.com/openimsdk/open-im-server/v3/pkg/localcache/link"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package lru // import "internal/pkg/pkg/localcache/lru"
package lru // import "github.com/openimsdk/open-im-server/v3/pkg/localcache/lru"

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package rpccache // import "internal/pkg/pkg/rpccache"
package rpccache // import "github.com/openimsdk/open-im-server/v3/pkg/rpccache"

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package grouphash // import "internal/pkg/pkg/rpcclient/grouphash"
package grouphash // import "github.com/openimsdk/open-im-server/v3/pkg/rpcclient/grouphash"

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -1,4 +1,4 @@
// Copyright © 2023 OpenIM. All rights reserved.
// Copyright © 2024 OpenIM. 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.

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package flag // import "internal/pkg/pkg/util/flag"
package flag // import "github.com/openimsdk/open-im-server/v3/pkg/util/flag"

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package genutil // import "internal/pkg/pkg/util/genutil"
package genutil // import "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"

@ -13,66 +13,72 @@
# See the License for the specific language governing permissions and
# limitations under the License.
DEFAULT_DIRS=(
"pkg"
"internal/pkg"
)
#!/bin/bash
DEFAULT_DIRS=("pkg")
BASE_URL="github.com/openimsdk/open-im-server/v3"
REMOVE_DOC=false
usage() {
echo "Usage: $0 [OPTIONS]"
echo
echo "This script iterates over directories and generates doc.go if necessary."
echo "By default, it processes 'pkg' and 'internal/pkg' directories."
echo "This script iterates over directories. By default, it generates doc.go files for 'pkg' and 'internal/pkg'."
echo
echo "Options:"
echo " -d DIRS, --dirs DIRS Specify the directories to be processed, separated by commas. E.g., 'pkg,internal/pkg'."
echo " -u URL, --url URL Set the base URL for the import path. Default is '$BASE_URL'."
echo " -h, --help Show this help message."
echo " -d DIRS, --dirs DIRS Specify directories to process, separated by commas (e.g., 'pkg,internal/pkg')."
echo " -u URL, --url URL Set the base URL for the import path. Default is '$BASE_URL'."
echo " -r, --remove Remove all doc.go files in the specified directories."
echo " -h, --help Show this help message."
echo
}
process_dir() {
local dir=$1
local base_url=$2
local dir="$1"
local base_url="$2"
local remove_doc="$3"
for d in $(find $dir -type d); do
if [ ! -f $d/doc.go ]; then
if ls $d/*.go > /dev/null 2>&1; then
echo $d/doc.go
echo "package $(basename $d) // import \"$base_url/$d\"" > $d/doc.go
find "$dir" -type d | while read -r d; do
if [ "$remove_doc" = true ]; then
if [ -f "$d/doc.go" ]; then
echo "Removing $d/doc.go"
rm -f "$d/doc.go"
fi
else
if [ ! -f "$d/doc.go" ] && ls "$d/"*.go &>/dev/null; then
echo "Creating $d/doc.go"
echo "package $(basename "$d") // import \"$base_url/$(echo "$d" | sed "s|^\./||")\"" >"$d/doc.go"
fi
fi
done
}
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
case "$1" in
-d|--dirs)
IFS=',' read -ra DIRS <<< "$2"
shift # shift past argument
shift # shift past value
;;
-u|--url)
BASE_URL="$2"
shift # shift past argument
shift # shift past value
;;
-h|--help)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
IFS=',' read -ra DIRS <<< "$2"
shift 2
;;
-u|--url)
BASE_URL="$2"
shift 2
;;
-r|--remove)
REMOVE_DOC=true
shift
;;
-h|--help)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
DIRS=${DIRS:-${DEFAULT_DIRS[@]}}
DIRS=(${DIRS:-"${DEFAULT_DIRS[@]}"})
for dir in "${DIRS[@]}"; do
process_dir $dir $BASE_URL
process_dir "$dir" "$BASE_URL" "$REMOVE_DOC"
done

Loading…
Cancel
Save