docs: add docs file and add copyright

pull/2100/head
Xinwei Xiong (cubxxw) 2 years ago
parent 1fa4511fb3
commit e46eed5208

@ -56,7 +56,8 @@ jobs:
- name: Generate all necessary files, such as error code files - name: Generate all necessary files, such as error code files
run: | run: |
make generate make gen.docgo.doc
make gen
echo "Generate all necessary files successfully" echo "Generate all necessary files successfully"
continue-on-error: true 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// Package startrpc start rpc server. package startrpc // import "github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
package startrpc

@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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 // See the License for the specific language governing permissions and
// limitations under the License. // 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,52 +13,58 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
DEFAULT_DIRS=( #!/bin/bash
"pkg"
"internal/pkg" DEFAULT_DIRS=("pkg")
)
BASE_URL="github.com/openimsdk/open-im-server/v3" BASE_URL="github.com/openimsdk/open-im-server/v3"
REMOVE_DOC=false
usage() { usage() {
echo "Usage: $0 [OPTIONS]" echo "Usage: $0 [OPTIONS]"
echo echo
echo "This script iterates over directories and generates doc.go if necessary." echo "This script iterates over directories. By default, it generates doc.go files for 'pkg' and 'internal/pkg'."
echo "By default, it processes 'pkg' and 'internal/pkg' directories."
echo echo
echo "Options:" echo "Options:"
echo " -d DIRS, --dirs DIRS Specify the directories to be processed, separated by commas. E.g., 'pkg,internal/pkg'." 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 " -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 " -h, --help Show this help message."
echo echo
} }
process_dir() { process_dir() {
local dir=$1 local dir="$1"
local base_url=$2 local base_url="$2"
local remove_doc="$3"
for d in $(find $dir -type d); do find "$dir" -type d | while read -r d; do
if [ ! -f $d/doc.go ]; then if [ "$remove_doc" = true ]; then
if ls $d/*.go > /dev/null 2>&1; then if [ -f "$d/doc.go" ]; then
echo $d/doc.go echo "Removing $d/doc.go"
echo "package $(basename $d) // import \"$base_url/$d\"" > $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
fi fi
done done
} }
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
key="$1" case "$1" in
case $key in
-d|--dirs) -d|--dirs)
IFS=',' read -ra DIRS <<< "$2" IFS=',' read -ra DIRS <<< "$2"
shift # shift past argument shift 2
shift # shift past value
;; ;;
-u|--url) -u|--url)
BASE_URL="$2" BASE_URL="$2"
shift # shift past argument shift 2
shift # shift past value ;;
-r|--remove)
REMOVE_DOC=true
shift
;; ;;
-h|--help) -h|--help)
usage usage
@ -71,8 +77,8 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
DIRS=${DIRS:-${DEFAULT_DIRS[@]}} DIRS=(${DIRS:-"${DEFAULT_DIRS[@]}"})
for dir in "${DIRS[@]}"; do for dir in "${DIRS[@]}"; do
process_dir $dir $BASE_URL process_dir "$dir" "$BASE_URL" "$REMOVE_DOC"
done done

Loading…
Cancel
Save