首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么kubebuilder在zz_generated.deepcopy.go文件中包括// +build!zz_generated.deepcopy.go?

为什么kubebuilder在zz_generated.deepcopy.go文件中包括// +build!zz_generated.deepcopy.go?
EN

Stack Overflow用户
提问于 2022-08-30 23:04:22
回答 1查看 137关注 0票数 1

make与kubebuilder一起生成的每个深度复制生成的文件都会在顶部生成一个带有// +build !ignore_autogenerated构建标记指令的文件。

代码语言:javascript
运行
复制
//go:build !ignore_autogenerated
// +build !ignore_autogenerated

/*
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.
*/

// Code generated by controller-gen. DO NOT EDIT.

为什么要将这个特定的构建标记指令添加到这些生成的文件中?其目的是什么?

EN

Stack Overflow用户

回答已采纳

发布于 2022-08-31 15:38:26

controller-gen使用它来标识它生成的文件,它只会覆盖这些文件。

例如,编辑生成的zz_generated.deepcopy.go并运行make generate =>,文件将被覆盖。

现在再次编辑该文件,还删除带有构建约束的两行( go:build行用于go >= 1.17,+build行用于较早版本的+build行),并再次运行make generate => --这次对该文件的更改没有被覆盖。

票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73549283

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档