自动生成Interface

This commit is contained in:
HuangJiaLuo 2021-09-20 20:51:56 +08:00
parent b03d096b53
commit 09b8907085
1 changed files with 14 additions and 12 deletions

View File

@ -65,19 +65,21 @@ def set_structure_const_template(conf: dict):
def set_structure_interface(conf):
print(conf)
# class KeyInterFace
with open(f"{structurePath}/interface.go") as fp:
interfaceText = fp.read()
for key, item in conf.items():
interfaceKey = "".join([k.capitalize() for k in key.split('_')])
interfaceTitle = "type "
text = load_template("interface.template")
Dic = {}
template = Template(text)
for i in conf.keys():
x = i.lower().title()
Dic["".join(x.split("_"))] = conf[i]
yamlData = [Dic]
text = template.render(Data=yamlData)
temp_path = f"{structurePath}/interface.gen.go"
with open(temp_path, 'w', encoding='utf-8') as f:
f.write(text)
if __name__ == "__main__":
conf, cfg_camel = load_conf()
set_structure_const_template(conf)
set_structure_interface(conf)
# set_structure_const_template(conf)
# set_structure_interface(conf)
set_structure_interface(cfg_camel)