代码拉取完成,页面将自动刷新
package dtomap
import (
"fmt"
"strings"
)
const (
classStart = "public class %s {"
classField = "%s public %s %s {get;set;}"
classEnd = "}"
separator = "\r\n"
NewClassAStart = "new A(){"
NewClassAField = "%s %s=temp.%s,"
)
type DestClass struct {
Name string
Fields []DestField
}
type DestField struct {
Name string
Type string
}
func (df *DestField) String() string {
return fmt.Sprintf(classField, separator, df.Type, df.Name)
}
func (df *DestField) NewClassString() string {
return fmt.Sprintf(NewClassAField, separator, df.Name, df.Name)
}
/*
public class A{
public int SysNo{get;set;}
public int SysNo2{get;set;}
}
*/
func (dc *DestClass) String() string {
sb := strings.Builder{}
sb.WriteString(fmt.Sprintf(classStart, dc.Name))
for _, field := range dc.Fields {
sb.WriteString(field.String())
}
sb.WriteString(separator)
sb.WriteString(classEnd)
return sb.String()
}
/*
new A(){
SysNo=tmp.SysNo,
SysNo2=tmp.SysNo2
}
*/
func (dc *DestClass) NewClassString() string {
sb := strings.Builder{}
sb.WriteString(NewClassAStart)
for _, field := range dc.Fields {
sb.WriteString(field.NewClassString())
}
sb.WriteString(separator)
sb.WriteString(classEnd)
return sb.String()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。