go: add os import in case of File return type (#3996)

This commit is contained in:
Nándor István Krácser 2019-10-01 05:31:55 +02:00 committed by William Cheng
parent 775d96c8e6
commit c8ac41c051

View File

@ -377,6 +377,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
boolean addedOSImport = false;
boolean addedReflectImport = false;
for (CodegenOperation operation : operations) {
// import "os" if the operation uses files
if (!addedOSImport && "*os.File".equals(operation.returnType)) {
imports.add(createMapping("import", "os"));
addedOSImport = true;
}
for (CodegenParameter param : operation.allParams) {
// import "os" if the operation uses files
if (!addedOSImport && "*os.File".equals(param.dataType)) {