使用 kubebuilder 生成的每個(gè) deepcopy 生成的文件都會(huì)生成一個(gè)頂部make帶有構(gòu)建標(biāo)記指令的文件。// +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.為什么要將這個(gè)特定的構(gòu)建標(biāo)記指令添加到這些生成的文件中?它的目的是什么?
1 回答

開(kāi)滿天機(jī)
TA貢獻(xiàn)1786條經(jīng)驗(yàn) 獲得超13個(gè)贊
它被controller-gen
用來(lái)識(shí)別它生成的文件,它只會(huì)覆蓋那些文件。
例如,編輯一個(gè)生成的文件zz_generated.deepcopy.go
并運(yùn)行make generate
=> 文件被覆蓋。
現(xiàn)在再次編輯文件,同時(shí)刪除帶有構(gòu)建約束的兩行(該go:build
行用于 go >= 1.17,+build
舊版本 IIRC 的行)并make generate
再次運(yùn)行 => 這次您對(duì)文件的更改沒(méi)有被覆蓋。
- 1 回答
- 0 關(guān)注
- 210 瀏覽
添加回答
舉報(bào)
0/150
提交
取消