Skip to content

Commit dddd61c

Browse files
committed
feat(metago): use context
1 parent dbd7412 commit dddd61c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ linters:
1717
- makezero
1818
- mnd
1919
- nlreturn
20-
- noctx
2120
- noinlineerr
2221
- paralleltest
2322
- prealloc

metago/metago.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package metago
44

55
import (
6+
"context"
67
"encoding/xml"
78
"errors"
89
"fmt"
@@ -19,9 +20,14 @@ type MetaGo struct {
1920
GoImport []string
2021
}
2122

22-
// Get gets go-get meta information from the meta tags.
23+
// Get gets go-get meta-information from the meta-tags.
2324
func Get(moduleName string) (*MetaGo, error) {
24-
req, err := http.NewRequest(http.MethodGet, makeURL(moduleName), nil)
25+
return GetWithContext(context.Background(), moduleName)
26+
}
27+
28+
// GetWithContext gets go-get meta-information from the meta-tags.
29+
func GetWithContext(ctx context.Context, moduleName string) (*MetaGo, error) {
30+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, makeURL(moduleName), nil)
2531
if err != nil {
2632
return nil, err
2733
}

0 commit comments

Comments
 (0)