Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use named return value and closure #8111

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions x/auth/client/cli/tx_multisign.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ recommended to set such parameters manually.
return cmd
}

func makeMultiSignCmd() func(cmd *cobra.Command, args []string) error {
func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) {
return func(cmd *cobra.Command, args []string) (err error) {
clientCtx := client.GetClientContextFromCmd(cmd)
clientCtx, err = client.ReadTxCommandFlags(clientCtx, cmd.Flags())
Expand Down Expand Up @@ -183,11 +183,17 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
if err = fp.Close(); err != nil {
return err
}

return clientCtx.PrintBytes(json)
defer func() {
err2 := fp.Close()
if err == nil {
err = err2
}
}()

err = clientCtx.PrintBytes(json)

return
}
}

Expand Down
18 changes: 12 additions & 6 deletions x/auth/client/cli/tx_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ func preSignCmd(cmd *cobra.Command, _ []string) {
}

func makeSignCmd() func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) (err error) {
clientCtx := client.GetClientContextFromCmd(cmd)
f := cmd.Flags()
clientCtx, err := client.ReadTxCommandFlags(clientCtx, f)
clientCtx, err = client.ReadTxCommandFlags(clientCtx, f)
if err != nil {
return err
}
Expand Down Expand Up @@ -295,11 +295,17 @@ func makeSignCmd() func(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
if err = fp.Close(); err != nil {
return err
}

return clientCtx.PrintBytes(json)
defer func() {
err2 := fp.Close()
if err == nil {
err = err2
}
}()

err = clientCtx.PrintBytes(json)

return
}
}

Expand Down