in lib/generator.js [1987:2028]
visitModelInterfaceBody(ast, structName, level) {
assert.equal(ast.type, 'modelBody');
this.emit(`String() string\n`, level);
this.emit(`GoString() string\n`, level);
for (let i = 0; i < ast.nodes.length; i++) {
const node = ast.nodes[i];
const fieldName = _format(_name(node.fieldName));
const fileldtype = structName + _format(fieldName);
const itemName = structName + _format(fieldName);
if (node.fieldValue.fieldType === 'array') {
if (_name(node.fieldValue.fieldItemType)) {
this.emit(`Set${fieldName}(v []${this.getType(_name(node.fieldValue.fieldItemType))}) *${structName}\n`, level);
} else if (node.fieldValue.fieldItemType.type === 'map') {
this.emit(`Set${fieldName}(v []`, level);
this.visitType(node.fieldValue.fieldItemType);
this.emit(`) *${structName}\n`);
} else if (node.fieldValue.fieldItemType.type === 'modelBody') {
this.emit(`Set${fieldName}(v []${this.getType(fileldtype)}) *${structName}\n`, level);
} else if (node.fieldValue.fieldItemType.fieldType === 'array') {
this.emit(`Set${fieldName}(v [][]`, level);
this.emitFuncArray(node.fieldValue.fieldItemType, itemName);
this.emit(`) *${structName}\n`);
}
} else if (node.fieldValue.type === 'modelBody') {
this.emit(`Set${fieldName}(v *${fileldtype}) *${structName}\n`, level);
} else if (_name(node.fieldValue.fieldType) && node.fieldValue.fieldType.idType === 'module') {
const fieldType = node.fieldValue.fieldType;
this.emit(`Set${fieldName}(v ${this.clientName[_name(fieldType)]}) *${structName}\n`, level);
} else if (node.fieldValue.fieldType.type === 'moduleModel' || node.fieldValue.fieldType.type === 'moduleTypedef' || node.fieldValue.fieldType.type === 'subModel') {
this.emit(`Set${fieldName}(v `, level);
this.visitType(node.fieldValue.fieldType, level);
this.emit(`) *${structName}\n`);
} else {
this.emit(`Set${fieldName}(v `, level);
this.visitType(node.fieldValue, level, {});
this.emit(`) *${structName}\n`);
}
this.emit(`Get${fieldName}() `, level);
this.visitFieldType(node, itemName, [], [], level);
this.emit('\n');
}
}