github.com/polarismesh/polaris@v1.17.8/import-format.sh (about)

     1  #!/bin/bash
     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  # 格式化 go.mod
    18  go mod tidy -compat=1.17
    19  
    20  # 处理 go imports 的格式化
    21  rm -rf style_tool
    22  rm -rf goimports-reviser
    23  
    24  mkdir -p style_tool
    25  
    26  cd style_tool
    27  
    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}
    41  mv goimports-reviser ../
    42  
    43  cd ../
    44  
    45  # 处理 go 代码格式化
    46  go fmt ./...
    47  
    48  find . -name "*.go" -type f | grep -v .pb.go | grep -v test/tools/tools.go | grep -v ./plugin.go |
    49      xargs -I {} ./goimports-reviser -rm-unused -format {} -local github.com/polarismesh/specification -project-name github.com/polarismesh/polaris