使用 kubebuilder 生成的每個 deepcopy 生成的文件都會生成一個頂部make帶有構建標記指令的文件。// +build !ignore_autogenerated//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.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.*/// Code generated by controller-gen. DO NOT EDIT.為什么要將這個特定的構建標記指令添加到這些生成的文件中?它的目的是什么?
1 回答

開滿天機
TA貢獻1786條經驗 獲得超13個贊
它被controller-gen
用來識別它生成的文件,它只會覆蓋那些文件。
例如,編輯一個生成的文件zz_generated.deepcopy.go
并運行make generate
=> 文件被覆蓋。
現在再次編輯文件,同時刪除帶有構建約束的兩行(該go:build
行用于 go >= 1.17,+build
舊版本 IIRC 的行)并make generate
再次運行 => 這次您對文件的更改沒有被覆蓋。
- 1 回答
- 0 關注
- 212 瀏覽
添加回答
舉報
0/150
提交
取消