Skip to content

Commit 84b528b

Browse files
neildgopherbot
authored andcommitted
internal/http3: new package
Create a package for an HTTP/3 implementation. Internal for now, intended to eventually move to x/net/http3. For golang/go#70914 Change-Id: I3a643fe7958cf75b231ca97f25e9f338554f723c Reviewed-on: https://go-review.googlesource.com/c/net/+/641836 Auto-Submit: Damien Neil <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 445eead commit 84b528b

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

internal/http3/doc.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2024 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Package http3 implements the HTTP/3 protocol.
6+
//
7+
// This package is a work in progress.
8+
// It is not ready for production usage.
9+
// Its API is subject to change without notice.
10+
package http3

internal/http3/files_test.go

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2025 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build go1.24
6+
7+
package http3
8+
9+
import (
10+
"bytes"
11+
"os"
12+
"strings"
13+
"testing"
14+
)
15+
16+
// TestFiles checks that every file in this package has a build constraint on Go 1.24.
17+
//
18+
// Package tests rely on testing/synctest, added as an experiment in Go 1.24.
19+
// When moving internal/http3 to an importable location, we can decide whether
20+
// to relax the constraint for non-test files.
21+
//
22+
// Drop this test when the x/net go.mod depends on 1.24 or newer.
23+
func TestFiles(t *testing.T) {
24+
f, err := os.Open(".")
25+
if err != nil {
26+
t.Fatal(err)
27+
}
28+
names, err := f.Readdirnames(-1)
29+
if err != nil {
30+
t.Fatal(err)
31+
}
32+
for _, name := range names {
33+
if !strings.HasSuffix(name, ".go") {
34+
continue
35+
}
36+
b, err := os.ReadFile(name)
37+
if err != nil {
38+
t.Fatal(err)
39+
}
40+
// Check for copyright header while we're in here.
41+
if !bytes.Contains(b, []byte("The Go Authors.")) {
42+
t.Errorf("%v: missing copyright", name)
43+
}
44+
// doc.go doesn't need a build constraint.
45+
if name == "doc.go" {
46+
continue
47+
}
48+
if !bytes.Contains(b, []byte("//go:build go1.24")) {
49+
t.Errorf("%v: missing constraint on go1.24", name)
50+
}
51+
if bytes.Contains(b, []byte(`"testing/synctest"`)) &&
52+
!bytes.Contains(b, []byte("//go:build go1.24 && goexperiment.synctest")) {
53+
t.Errorf("%v: missing constraint on go1.24 && goexperiment.synctest", name)
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)