自定义内容/标记对
- 自动生成代码,必然是会进行多次,不会只生成一次就OK了
- 这样,就存在一个问题,生成的代码不满足需求,需要自行修改时,自动生成的代码、自定义的代码如何共存?如何保证重新生成时自定义的代码不会被覆盖掉?
- 为了解决这个问题,i3go_codemaker生成的代码中,使用了大量的标记,用于添加自定义内容
比如Model代码中:
上面的//customRefrenceBegin、//customRefrenceEnd就是一对标记,它们中间的内容在重新生成时会保留
package model import ( //customRefrenceBegin "time" //customRefrenceEnd ) //ConsumeRecord .. type ConsumeRecord struct { ID string `json:"id" db:"id" ` CreateTime time.Time `json:"createTime" db:"createTime" ` Type string `json:"type" db:"type" ` Value float32 `json:"value" db:"value" ` //customContentBegin //customContentEnd }
- Model、Mapper、Service中包含大量的标记,有针对方法内部的、有针对代码文件的,以//xxxxBegin、//xxxxEnd成对的形式出现
- 不在标记对中的代码,在重新生成后会丢失