Fix mockgen generated files not group imports issue
Signed-off-by: RainbowMango <qdurenhongcai@gmail.com>
This commit is contained in:
parent
f869fbac16
commit
82b61dcc69
|
@ -22,7 +22,7 @@ SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
|||
cd "${SCRIPT_ROOT}"
|
||||
ROOT_PATH=$(pwd)
|
||||
|
||||
GO111MODULE=on go install "golang.org/x/tools/cmd/goimports@v0.1.5"
|
||||
GO111MODULE=on go install "golang.org/x/tools/cmd/goimports"
|
||||
|
||||
IMPORT_ALIASES_PATH="${ROOT_PATH}/hack/.import-aliases"
|
||||
INCLUDE_PATH="(${ROOT_PATH}/cmd|${ROOT_PATH}/test/e2e|${ROOT_PATH}/test/helper|\
|
||||
|
|
|
@ -30,11 +30,16 @@ trap EXIT
|
|||
|
||||
echo 'installing mockgen'
|
||||
source "${KARMADA_ROOT}"/hack/util.sh
|
||||
echo -n "Preparing: 'mockgen' existence check - "
|
||||
echo "Preparing: 'mockgen' existence check - "
|
||||
if [ ! $(util::cmd_exist mockgen) ]; then
|
||||
# install from vendor with the pinned version in go.mod file
|
||||
GO111MODULE=on go install "go.uber.org/mock/mockgen"
|
||||
fi
|
||||
echo "Preparing: 'goimports' existence check - "
|
||||
if [ ! $(util::cmd_exist goimports) ]; then
|
||||
# install from vendor with the pinned version in go.mod file
|
||||
GO111MODULE=on go install "golang.org/x/tools/cmd/goimports"
|
||||
fi
|
||||
|
||||
find_files() {
|
||||
find . -not \( \
|
||||
|
|
|
@ -14,7 +14,12 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Given mockgen does not group imports according to our project's conventions.
|
||||
// Following the mockgen command, we run 'goimports', which reformats the
|
||||
// generated file to ensure that all imports are properly grouped and sorted,
|
||||
// maintaining consistency with the rest of our codebase.
|
||||
//go:generate mockgen -source=interface.go -destination=testing/mock_interface.go -package=testing FilterPlugin ScorePlugin ScoreExtensions
|
||||
//go:generate goimports -local "github.com/karmada-io/karmada" -w testing/mock_interface.go
|
||||
|
||||
package framework
|
||||
|
||||
|
|
|
@ -13,10 +13,11 @@ import (
|
|||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
|
||||
v1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
|
||||
v1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
|
||||
framework "github.com/karmada-io/karmada/pkg/scheduler/framework"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
// MockFramework is a mock of Framework interface.
|
||||
|
|
Loading…
Reference in New Issue