Skip to content

Commit cfcde89

Browse files
committed
fix: fix some options
1 parent 1dec90c commit cfcde89

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

cmd/sponge/commands/generate/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ func adaptPgDsn(dsn string) string {
870870

871871
u, err := url.Parse(dsn)
872872
if err != nil {
873-
panic(err)
873+
return dsn
874874
}
875875

876876
if u.RawQuery == "" {

cmd/sponge/commands/generate/http.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ func HTTPCommand() *cobra.Command {
8787
return err
8888
}
8989
g := &httpGenerator{
90-
moduleName: moduleName,
91-
serverName: serverName,
92-
projectName: projectName,
93-
repoAddr: repoAddr,
94-
dbDSN: sqlArgs.DBDsn,
95-
dbDriver: sqlArgs.DBDriver,
96-
codes: codes,
97-
outPath: outPath,
98-
isExtendedAPI: sqlArgs.IsExtendedAPI,
99-
90+
moduleName: moduleName,
91+
serverName: serverName,
92+
projectName: projectName,
93+
repoAddr: repoAddr,
94+
dbDSN: sqlArgs.DBDsn,
95+
dbDriver: sqlArgs.DBDriver,
96+
codes: codes,
97+
outPath: outPath,
98+
isExtendedAPI: sqlArgs.IsExtendedAPI,
99+
isEmbed: sqlArgs.IsEmbed,
100100
suitedMonoRepo: suitedMonoRepo,
101101
}
102102
outPath, err = g.generateCode()

pkg/grpc/grpccli/option.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ func WithEnableLog(log *zap.Logger) Option {
9696
o.enableLog = true
9797
if log != nil {
9898
o.log = log
99-
} else {
100-
o.log = zap.NewNop()
99+
return
101100
}
101+
o.log, _ = zap.NewProduction()
102102
}
103103
}
104104

pkg/httpcli/httpcli.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,18 +347,14 @@ func defaultOptions() *options {
347347
// WithParams set params
348348
func WithParams(params map[string]interface{}) Option {
349349
return func(o *options) {
350-
if o.params != nil {
351-
o.params = params
352-
}
350+
o.params = params
353351
}
354352
}
355353

356354
// WithHeaders set headers
357355
func WithHeaders(headers map[string]string) Option {
358356
return func(o *options) {
359-
if o.headers != nil {
360-
o.headers = headers
361-
}
357+
o.headers = headers
362358
}
363359
}
364360

pkg/logger/option.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func WithFileName(filename string) FileOption {
130130
// WithFileMaxSize set maximum file size (MB)
131131
func WithFileMaxSize(maxSize int) FileOption {
132132
return func(f *fileOptions) {
133-
if f.maxSize > 0 {
133+
if maxSize > 0 {
134134
f.maxSize = maxSize
135135
}
136136
}

0 commit comments

Comments
 (0)