github.com/jpmicrosoft/grab/v3@v3.0.2/pkg/grabui/grabui.go (about) 1 package grabui 2 3 import ( 4 "context" 5 6 "github.com/jpmicrosoft/grab/v3" 7 ) 8 9 func GetBatch( 10 ctx context.Context, 11 workers int, 12 dst string, 13 urlStrs ...string, 14 ) (<-chan *grab.Response, error) { 15 reqs := make([]*grab.Request, len(urlStrs)) 16 for i := 0; i < len(urlStrs); i++ { 17 req, err := grab.NewRequest(dst, urlStrs[i]) 18 if err != nil { 19 return nil, err 20 } 21 req = req.WithContext(ctx) 22 reqs[i] = req 23 } 24 25 ui := NewConsoleClient(grab.DefaultClient) 26 return ui.Do(ctx, workers, reqs...), nil 27 }