Skip to content

Commit d6006df

Browse files
committed
Fixing issues with geoip example
1 parent 5faeeeb commit d6006df

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

geoip/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
Run like the following:
44

55
```sh
6-
$ go run main.go $(curl -s ifconfig.me)
6+
$ go run main.go $(curl -s ifconfig.me) 92.87.44.226 75.181.186.168
77
```

geoip/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func run(ctx context.Context, verbose bool, timeout time.Duration, lang string,
4848
ctx, cancel := chromedp.NewContext(ctx, opts...)
4949
defer cancel()
5050

51+
// create timeout
52+
ctx, cancel = context.WithTimeout(ctx, timeout)
53+
defer cancel()
54+
5155
for i, ipstr := range args {
5256
if i != 0 {
5357
fmt.Fprintln(os.Stdout)
@@ -98,8 +102,6 @@ func run(ctx context.Context, verbose bool, timeout time.Duration, lang string,
98102

99103
func getMap(ctx context.Context, timeout time.Duration, lat, lng, zoom, scale float64) (image.Image, error) {
100104
// create a timeout
101-
ctx, cancel := context.WithTimeout(ctx, timeout)
102-
defer cancel()
103105
var address string
104106
var buf []byte
105107
if err := chromedp.Run(ctx,

0 commit comments

Comments
 (0)