You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
subCtx, subCancel:=context.WithCancel(ctx)//nolint:gosec // G118: cancel stored in subscriber struct, called via unsubscribe or parent context cancellation
Copy file name to clipboardExpand all lines: examples/sse_client.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -28,14 +28,14 @@ func main() {
28
28
req.Header.Set("Accept", "text/event-stream")
29
29
30
30
client:=&http.Client{}
31
-
resp, err:=client.Do(req)//nolint:gosec // G704: URL is constructed from a localhost constant, not user input
31
+
resp, err:=client.Do(req)
32
32
iferr!=nil {
33
33
log.Fatal(err)
34
34
}
35
35
deferfunc() { _=resp.Body.Close() }()
36
36
37
37
ifresp.StatusCode!=http.StatusOK {
38
-
log.Fatalf("Failed to connect: %s", resp.Status)//nolint:gosec // G706: resp.Status is from the HTTP response, not external user input
38
+
log.Fatalf("Failed to connect: %s", resp.Status)
39
39
}
40
40
41
41
log.Println("Connected to SSE stream...")
@@ -49,7 +49,7 @@ func main() {
49
49
ifline=="" {
50
50
// Empty line signals end of event
51
51
ifeventData!="" {
52
-
log.Printf("[ID: %s] [Type: %s] %s\n", eventID, eventType, eventData)//nolint:gosec // G706: SSE event data is parsed from trusted server response in this example
0 commit comments