Skip to content

Commit

Permalink
fix: fix some options
Browse files Browse the repository at this point in the history
  • Loading branch information
zhufuyi committed Oct 27, 2024
1 parent 1dec90c commit cfcde89
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmd/sponge/commands/generate/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ func adaptPgDsn(dsn string) string {

u, err := url.Parse(dsn)
if err != nil {
panic(err)
return dsn
}

if u.RawQuery == "" {
Expand Down
20 changes: 10 additions & 10 deletions cmd/sponge/commands/generate/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ func HTTPCommand() *cobra.Command {
return err
}
g := &httpGenerator{
moduleName: moduleName,
serverName: serverName,
projectName: projectName,
repoAddr: repoAddr,
dbDSN: sqlArgs.DBDsn,
dbDriver: sqlArgs.DBDriver,
codes: codes,
outPath: outPath,
isExtendedAPI: sqlArgs.IsExtendedAPI,

moduleName: moduleName,
serverName: serverName,
projectName: projectName,
repoAddr: repoAddr,
dbDSN: sqlArgs.DBDsn,
dbDriver: sqlArgs.DBDriver,
codes: codes,
outPath: outPath,
isExtendedAPI: sqlArgs.IsExtendedAPI,
isEmbed: sqlArgs.IsEmbed,
suitedMonoRepo: suitedMonoRepo,
}
outPath, err = g.generateCode()
Expand Down
4 changes: 2 additions & 2 deletions pkg/grpc/grpccli/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ func WithEnableLog(log *zap.Logger) Option {
o.enableLog = true
if log != nil {
o.log = log
} else {
o.log = zap.NewNop()
return
}
o.log, _ = zap.NewProduction()
}
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/httpcli/httpcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,14 @@ func defaultOptions() *options {
// WithParams set params
func WithParams(params map[string]interface{}) Option {
return func(o *options) {
if o.params != nil {
o.params = params
}
o.params = params
}
}

// WithHeaders set headers
func WithHeaders(headers map[string]string) Option {
return func(o *options) {
if o.headers != nil {
o.headers = headers
}
o.headers = headers
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/logger/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func WithFileName(filename string) FileOption {
// WithFileMaxSize set maximum file size (MB)
func WithFileMaxSize(maxSize int) FileOption {
return func(f *fileOptions) {
if f.maxSize > 0 {
if maxSize > 0 {
f.maxSize = maxSize
}
}
Expand Down

0 comments on commit cfcde89

Please sign in to comment.