mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-27 16:07:42 +08:00
remove some dead code
(it was causing go vet to complain) License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
@ -135,11 +135,6 @@ func (r *requestWrapper) SetOptions(om cmdkit.OptMap) error {
|
||||
return convertOptions(r.req)
|
||||
}
|
||||
|
||||
func (r *requestWrapper) SetRootContext(ctx context.Context) error {
|
||||
r.req.Context = ctx
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *requestWrapper) Stdin() io.Reader {
|
||||
return os.Stdin
|
||||
}
|
||||
|
@ -120,7 +120,6 @@ type Request interface {
|
||||
Files() files.File
|
||||
SetFiles(files.File)
|
||||
Context() context.Context
|
||||
SetRootContext(context.Context) error
|
||||
InvocContext() *Context
|
||||
SetInvocContext(Context)
|
||||
Command() *Command
|
||||
@ -185,16 +184,6 @@ func (r *request) Options() cmdkit.OptMap {
|
||||
return output
|
||||
}
|
||||
|
||||
func (r *request) SetRootContext(ctx context.Context) error {
|
||||
ctx, err := getContext(ctx, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.rctx = ctx
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetOption sets the value of the option for given name.
|
||||
func (r *request) SetOption(name string, val interface{}) {
|
||||
// find the option with the specified name
|
||||
@ -308,28 +297,6 @@ func (r *request) VarArgs(f func(string) error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getContext(base context.Context, req Request) (context.Context, error) {
|
||||
tout, found, err := req.Option("timeout").String()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing timeout option: %s", err)
|
||||
}
|
||||
|
||||
var ctx context.Context
|
||||
if found {
|
||||
duration, err := time.ParseDuration(tout)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing timeout option: %s", err)
|
||||
}
|
||||
|
||||
tctx, _ := context.WithTimeout(base, duration)
|
||||
ctx = tctx
|
||||
} else {
|
||||
cctx, _ := context.WithCancel(base)
|
||||
ctx = cctx
|
||||
}
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
func (r *request) InvocContext() *Context {
|
||||
return &r.ctx
|
||||
}
|
||||
|
Reference in New Issue
Block a user