forked from p93542168/wheat-cache
自动生成Interface
This commit is contained in:
parent
b03d096b53
commit
09b8907085
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue