Skip to content

Instantly share code, notes, and snippets.

@kulti
kulti / http_response_writer.go
Last active June 1, 2022 06:52
Wrap http.ResponseWriter with proxying another interfaces
func wrapResponseWriter(w http.ResponseWriter, codeHook func(int)) http.ResponseWriter {
rw := &rw{w: w, codeHook: codeHook}
hj, hasHijack := w.(http.Hijacker)
fl, hasFlusher := w.(http.Flusher)
rf, hasReadFrom := w.(io.ReaderFrom)
switch {
case hasHijack && hasFlusher && hasReadFrom:
return struct {
http.ResponseWriter
@kulti
kulti / .golangci.yml
Last active January 24, 2024 10:30
golangci-lint config workflow
# Comments started with [!] are explanations of my workflow with golangci-lint.
# Another comments are real comments in my config.
# [!] Examine the https://golangci-lint.run/usage/configuration/ to know all possibilities.
run:
timeout: 5m
modules-download-mode: vendor # [!] if you are using vendoring
build-tags:
- integration # [!] If you disable code for integration tests to run all unit tests, enable it to lint all the same.
package hw06pipelineexecution
import (
"strconv"
"testing"
"time"
"github.com/stretchr/testify/require"
)