Skip to content

Commit 13ad52c

Browse files
jpbetzthockin
andcommitted
Disable the insertion and deletion of imports
Co-authored-by: Tim Hockin <[email protected]>
1 parent a7b603a commit 13ad52c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

v2/generator/execute.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"strings"
2727

2828
"golang.org/x/tools/imports"
29+
2930
"k8s.io/gengo/v2/namer"
3031
"k8s.io/gengo/v2/types"
3132
"k8s.io/klog/v2"
@@ -114,7 +115,13 @@ func assembleGoFile(w io.Writer, f *File) {
114115
}
115116

116117
func importsWrapper(src []byte) ([]byte, error) {
117-
return imports.Process("", src, nil)
118+
opt := imports.Options{
119+
Comments: true,
120+
TabIndent: true,
121+
TabWidth: 8,
122+
FormatOnly: true, // Disable the insertion and deletion of imports
123+
}
124+
return imports.Process("", src, &opt)
118125
}
119126

120127
func NewGoFile() *DefaultFileType {

0 commit comments

Comments
 (0)