MCPcopy Index your code
hub / github.com/zeromicro/go-zero / MySqlDataSource

Function MySqlDataSource

tools/goctl/model/sql/command/command.go:103–145  ·  view source on GitHub ↗

MySqlDataSource generates model code from datasource

(_ *cobra.Command, _ []string)

Source from the content-addressed store, hash-verified

101
102// MySqlDataSource generates model code from datasource
103func MySqlDataSource(_ *cobra.Command, _ []string) error {
104 migrationnotes.BeforeCommands(VarStringDir, VarStringStyle)
105 if VarBoolCache && len(VarStringCachePrefix) == 0 {
106 return errors.New("cache prefix is empty")
107 }
108 url := strings.TrimSpace(VarStringURL)
109 dir := strings.TrimSpace(VarStringDir)
110 cache := VarBoolCache
111 idea := VarBoolIdea
112 style := VarStringStyle
113 home := VarStringHome
114 remote := VarStringRemote
115 branch := VarStringBranch
116 if len(remote) > 0 {
117 repo, _ := file.CloneIntoGitHome(remote, branch)
118 if len(repo) > 0 {
119 home = repo
120 }
121 }
122 if len(home) > 0 {
123 pathx.RegisterGoctlHome(home)
124 }
125
126 tableValue := VarStringSliceTable
127 patterns := parseTableList(tableValue)
128 cfg, err := config.NewConfig(style)
129 if err != nil {
130 return err
131 }
132
133 arg := dataSourceArg{
134 url: url,
135 dir: dir,
136 tablePat: patterns,
137 cfg: cfg,
138 cache: cache,
139 idea: idea,
140 strict: VarBoolStrict,
141 ignoreColumns: mergeColumns(VarStringSliceIgnoreColumns),
142 prefix: VarStringCachePrefix,
143 }
144 return fromMysqlDataSource(arg)
145}
146
147func mergeColumns(columns []string) []string {
148 set := collection.NewSet[string]()

Callers

nothing calls this directly

Calls 6

BeforeCommandsFunction · 0.92
RegisterGoctlHomeFunction · 0.92
NewConfigFunction · 0.92
parseTableListFunction · 0.85
mergeColumnsFunction · 0.85
fromMysqlDataSourceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…