Skip to content

Commit 5038ed1

Browse files
committed
improve code
1 parent cb7c567 commit 5038ed1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

internal/commands/mt.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package commands
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"strconv"
98
"strings"
@@ -283,11 +282,11 @@ func obtainMTCmd(context *cli.Context) error {
283282
opts.Capabilities = api.NewCapabilities(config.Get().DefaultTokenCapabilities.Returned)
284283
}
285284

286-
st, err := obtainMT(opts, context, mtCommand.Tag, mtCommand.TokenType)
285+
st, err := obtainMT(&opts, context, mtCommand.Tag, mtCommand.TokenType)
287286
if err != nil {
288287
return err
289288
}
290-
return ioutil.WriteFile(mtCommand.Out, append([]byte(st), '\n'), 0600)
289+
return os.WriteFile(mtCommand.Out, append([]byte(st), '\n'), 0600)
291290
}
292291

293292
func parseRestrictionOpts(opts *restrictionOpts, ctx *cli.Context) (r api.Restrictions, err error) {
@@ -325,7 +324,7 @@ func parseRestrictionOpts(opts *restrictionOpts, ctx *cli.Context) (r api.Restri
325324
return
326325
}
327326

328-
func obtainMT(opts commonMTOpts, context *cli.Context, name, responseType string) (string, error) {
327+
func obtainMT(opts *commonMTOpts, context *cli.Context, name, responseType string) (string, error) {
329328
mytoken := config.Get().Mytoken
330329
if opts.TransferCode != "" {
331330
return mytoken.Mytoken.FromTransferCode(opts.TransferCode)
@@ -443,7 +442,7 @@ func storeMTCmd(context *cli.Context) error {
443442
os.Exit(1)
444443
}
445444
}
446-
mt, err := obtainMT(opts, context, storeName, api.ResponseTypeToken)
445+
mt, err := obtainMT(&opts, context, storeName, api.ResponseTypeToken)
447446
if err != nil {
448447
return err
449448
}
@@ -488,7 +487,7 @@ func parseRestrictionOption(arg string) (api.Restrictions, error) {
488487
if arg[0] == '[' || arg[0] == '{' {
489488
return parseRestrictions(arg)
490489
}
491-
data, err := ioutil.ReadFile(arg)
490+
data, err := os.ReadFile(arg)
492491
if err != nil {
493492
return nil, err
494493
}

0 commit comments

Comments
 (0)