Skip to content

Commit c2ec703

Browse files
committed
style:fix import order and add license header
1 parent fbef639 commit c2ec703

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+727
-55
lines changed

.golangci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ linters-settings:
146146
- name: import-shadowing
147147
severity: warning
148148
disabled: false
149-
arguments: [ "github.com/polarismesh/polaris","namespace" ]
149+
arguments: [ "github.com/polaris-contrib/store-postgresql","namespace" ]
150150
- name: waitgroup-by-value
151151
severity: warning
152152
disabled: false
@@ -355,7 +355,7 @@ linters-settings:
355355
sections:
356356
- standard # Standard section: captures all standard packages.
357357
- default # Default section: contains all imports that could not be matched to another section type.
358-
- prefix(github.com/pole-group/nacosserver) # Custom section: groups all imports with the specified Prefix.
358+
- prefix(github.com/polaris-contrib/store-postgresql) # Custom section: groups all imports with the specified Prefix.
359359
#- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
360360
#- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
361361
# Skip generated files.

import-format.sh

+14-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations under the License.
1616

1717
# 格式化 go.mod
18-
go mod tidy -compat=1.18
18+
go mod tidy -compat=1.17
1919

2020
# 处理 go imports 的格式化
2121
rm -rf style_tool
@@ -25,8 +25,19 @@ mkdir -p style_tool
2525

2626
cd style_tool
2727

28-
wget https://github.com/incu6us/goimports-reviser/releases/download/v3.1.1/goimports-reviser_3.1.1_linux_amd64.tar.gz
29-
tar -zxvf goimports-reviser_3.1.1_linux_amd64.tar.gz
28+
is_arm=$(/usr/bin/uname -m | grep "arm|aarch64" | wc -l)
29+
goimports_target_file="goimports-reviser_3.3.1_linux_amd64.tar.gz"
30+
31+
if [ "$(uname)" == "Darwin" ]; then
32+
if [ "${is_arm}" == "1" ]; then
33+
goimports_target_file="goimports-reviser_3.3.1_darwin_arm64.tar.gz"
34+
else
35+
goimports_target_file="goimports-reviser_3.3.1_darwin_amd64.tar.gz"
36+
fi
37+
fi
38+
39+
wget "https://github.com/incu6us/goimports-reviser/releases/download/v3.3.1/${goimports_target_file}"
40+
tar -zxvf ${goimports_target_file}
3041
mv goimports-reviser ../
3142

3243
cd ../

pgstore.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
package pgstore
1919

2020
import (
21-
"github.com/polaris-contrib/store-postgresql/store/postgresql"
2221
"github.com/polarismesh/polaris/common/log"
2322
"github.com/polarismesh/polaris/store"
23+
24+
"github.com/polaris-contrib/store-postgresql/store/postgresql"
2425
)
2526

2627
func init() {

store/postgresql/admin.go

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
118
package postgresql
219

320
import (
421
"context"
522
"database/sql"
623
"fmt"
7-
"github.com/polarismesh/polaris/common/eventhub"
8-
"github.com/polarismesh/polaris/common/log"
9-
"github.com/polarismesh/polaris/common/model"
10-
"github.com/polarismesh/polaris/common/utils"
11-
"github.com/polarismesh/polaris/store"
1224
"sync"
1325
"sync/atomic"
1426
"time"
1527

1628
_ "github.com/lib/pq"
29+
"github.com/polarismesh/polaris/common/eventhub"
30+
"github.com/polarismesh/polaris/common/log"
31+
"github.com/polarismesh/polaris/common/model"
32+
"github.com/polarismesh/polaris/common/utils"
33+
"github.com/polarismesh/polaris/store"
1734
)
1835

1936
const (

store/postgresql/admin_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
118
package postgresql
219

320
import (

store/postgresql/base_db.go

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
118
package postgresql
219

320
import (
421
"context"
522
"database/sql"
623
"fmt"
7-
"github.com/polarismesh/polaris/common/log"
8-
"github.com/polarismesh/polaris/plugin"
924
"strings"
1025
"time"
1126

1227
_ "github.com/lib/pq"
28+
"github.com/polarismesh/polaris/common/log"
29+
"github.com/polarismesh/polaris/plugin"
1330
)
1431

1532
// db抛出的异常,需要重试的字符串组

store/postgresql/base_db_test.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
118
package postgresql
219

320
import (
421
"errors"
522
"fmt"
6-
. "github.com/smartystreets/goconvey/convey"
723
"testing"
824
"time"
25+
26+
. "github.com/smartystreets/goconvey/convey"
927
)
1028

1129
func TestRetry(t *testing.T) {

store/postgresql/circuitbreaker_config.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
118
package postgresql
219

320
import (
421
"database/sql"
522
"fmt"
23+
"time"
24+
625
"github.com/polarismesh/polaris/common/log"
726
"github.com/polarismesh/polaris/common/model"
827
"github.com/polarismesh/polaris/store"
9-
"time"
1028
)
1129

1230
const (

store/postgresql/circuitbreaker_config_v2.go

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
118
package postgresql
219

320
import (
421
"database/sql"
522
"fmt"
6-
"github.com/polarismesh/polaris/common/log"
7-
"github.com/polarismesh/polaris/common/model"
8-
"github.com/polarismesh/polaris/store"
923
"strconv"
1024
"strings"
1125
"time"
26+
27+
"github.com/polarismesh/polaris/common/log"
28+
"github.com/polarismesh/polaris/common/model"
29+
"github.com/polarismesh/polaris/store"
1230
)
1331

1432
const (

store/postgresql/client.go

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
118
package postgresql
219

320
import (
421
"database/sql"
522
"errors"
623
"fmt"
24+
"strings"
25+
"time"
26+
727
"github.com/polarismesh/polaris/common/log"
828
"github.com/polarismesh/polaris/common/model"
929
"github.com/polarismesh/polaris/store"
1030
apiservice "github.com/polarismesh/specification/source/go/api/v1/service_manage"
11-
"strings"
12-
"time"
1331
)
1432

1533
type clientStore struct {

store/postgresql/client_test.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
118
package postgresql
219

320
import (
421
"fmt"
22+
"testing"
23+
524
"github.com/polarismesh/polaris/common/model"
625
apimodel "github.com/polarismesh/specification/source/go/api/v1/model"
726
apiservice "github.com/polarismesh/specification/source/go/api/v1/service_manage"
827
"google.golang.org/protobuf/types/known/wrapperspb"
9-
"testing"
1028
)
1129

1230
func createMockClients(total int) []*model.Client {

store/postgresql/common.go

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
118
package postgresql
219

320
import (
421
"bytes"
522
"database/sql"
6-
"github.com/polarismesh/polaris/common/log"
7-
"github.com/polarismesh/polaris/store"
823
"strings"
924
"time"
1025
"unicode"
26+
27+
"github.com/polarismesh/polaris/common/log"
28+
"github.com/polarismesh/polaris/store"
1129
)
1230

1331
func toUnderscoreName(name string) string {

store/postgresql/config.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making Polaris available.
3+
*
4+
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the BSD 3-Clause License (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* https://opensource.org/licenses/BSD-3-Clause
11+
*
12+
* Unless required by applicable law or agreed to in writing, software distributed
13+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations under the License.
16+
*/
17+
118
package postgresql
219

320
import (
@@ -26,7 +43,7 @@ type Pgsql struct {
2643
PwdField string `json:"pwdField"`
2744
}
2845

29-
//配置文件路径
46+
// 配置文件路径
3047
var ConfigPath string = "config/config.json"
3148

3249
// postgresql配置信息缓存

0 commit comments

Comments
 (0)