From ec501e4dc3cba2d3446b3c872af1bc057b5a28f3 Mon Sep 17 00:00:00 2001 From: Laurent Demailly Date: Sun, 1 Mar 2026 10:05:08 -0800 Subject: [PATCH 1/4] adding ci and fixing linter detected complaints --- .github/workflows/include.yml | 31 +++++++++++++++++++++++++++++++ .gitignore | 1 + Dockerfile | 4 ++++ h2cli.go | 8 +++++--- 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/include.yml create mode 100644 Dockerfile diff --git a/.github/workflows/include.yml b/.github/workflows/include.yml new file mode 100644 index 0000000..743e326 --- /dev/null +++ b/.github/workflows/include.yml @@ -0,0 +1,31 @@ +# Same as full workflow (eg from fortio/gvi) but without the goreleaser step +name: "shared fortio workflows" + +on: + push: + branches: [ main ] # put back once testing with pre-releases on branch is done. + tags: + - 'v*' + pull_request: + branches: [ main ] + +jobs: + call-gochecks: + uses: fortio/workflows/.github/workflows/gochecks.yml@main + call-codecov: + uses: fortio/workflows/.github/workflows/codecov.yml@main + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + call-codeql: + uses: fortio/workflows/.github/workflows/codeql-analysis.yml@main + releaser-h2cli: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + uses: fortio/workflows/.github/workflows/releaser.yml@main + with: + description: "Simple http 2.0 (h2 and h2c) client in go, including streaming" + binary_name: "h2cli" + dockerfile: "./Dockerfile" + secrets: + GH_PAT: ${{ secrets.GH_PAT }} + DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} + DOCKER_USER: ${{ secrets.DOCKER_USER }} diff --git a/.gitignore b/.gitignore index 66fd13c..aaf1d79 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ # Dependency directories (remove the comment below to include it) # vendor/ +.golangci.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8ffe6f1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM scratch +COPY h2cli /usr/bin/h2cli +ENV HOME=/home/user +ENTRYPOINT ["/usr/bin/h2cli"] diff --git a/h2cli.go b/h2cli.go index f224487..b0cec92 100644 --- a/h2cli.go +++ b/h2cli.go @@ -72,8 +72,9 @@ func main() { AllowHTTP: true, // to get h2c // Trick to get h2c without TLS: // thanks to https://github.com/thrawn01/h2c-golang-example/blob/master/README.md - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - return net.Dial(network, addr) + DialTLSContext: func(ctx context.Context, network, addr string, _ *tls.Config) (net.Conn, error) { + var d net.Dialer + return d.DialContext(ctx, network, addr) }, } } @@ -92,7 +93,8 @@ func main() { log.Fatalf("Failed %q %q - error: %v", *method, *urlFlag, err) } if *stream { - n, err := io.Copy(os.Stdout, resp.Body) + var n int64 + n, err = io.Copy(os.Stdout, resp.Body) log.Infof("Response code %d, proto %s, size %d", resp.StatusCode, resp.Proto, n) if err != nil { log.Fatalf("Error copying response body: %v", err) From 07e1f061759cb5f1b791877c72336cb5024b3f4a Mon Sep 17 00:00:00 2001 From: Laurent Demailly Date: Sun, 1 Mar 2026 10:48:35 -0800 Subject: [PATCH 2/4] add note, mostly to rerun ci --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1d210f1..9f81983 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ Simple http 2.0 (h2) client in go including h2c (http2 over clear text, not requ go install github.com/fortio/h2cli@latest ``` +or see the binary releases. + ## Running Options/flags: From 9faa799401070a1466b21d8ac21aff9b946541df Mon Sep 17 00:00:00 2001 From: Laurent Demailly Date: Sun, 1 Mar 2026 10:53:03 -0800 Subject: [PATCH 3/4] gosec.... --- h2cli.go | 1 + 1 file changed, 1 insertion(+) diff --git a/h2cli.go b/h2cli.go index b0cec92..3a066d4 100644 --- a/h2cli.go +++ b/h2cli.go @@ -88,6 +88,7 @@ func main() { if err != nil { log.Fatalf("Request method %q url %q error: %v", *method, *urlFlag, err) } + //nolint:gosec // yes we want to fetch the url given as input. resp, err := client.Do(req) if err != nil { log.Fatalf("Failed %q %q - error: %v", *method, *urlFlag, err) From 83406b24c730eab37ebb95f32a03db9c50ecaa07 Mon Sep 17 00:00:00 2001 From: Laurent Demailly Date: Sun, 1 Mar 2026 10:54:01 -0800 Subject: [PATCH 4/4] skip codecov for now --- .github/workflows/include.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/include.yml b/.github/workflows/include.yml index 743e326..a0986ec 100644 --- a/.github/workflows/include.yml +++ b/.github/workflows/include.yml @@ -12,10 +12,10 @@ on: jobs: call-gochecks: uses: fortio/workflows/.github/workflows/gochecks.yml@main - call-codecov: - uses: fortio/workflows/.github/workflows/codecov.yml@main - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} +# call-codecov: +# uses: fortio/workflows/.github/workflows/codecov.yml@main +# secrets: +# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} call-codeql: uses: fortio/workflows/.github/workflows/codeql-analysis.yml@main releaser-h2cli: