aboutsummaryrefslogtreecommitdiff
path: root/internal/stdlib/testdata/dev.fuzz/src
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2021-06-23 16:36:40 -0700
committerJulie Qiu <julie@golang.org>2021-07-12 21:13:20 +0000
commite6b30bf2f78149bbea1ef607321cdeed1010abc5 (patch)
treefe76ed9ca0f6a83124a1130e797c2da10c04fcfc /internal/stdlib/testdata/dev.fuzz/src
parent738f3de8876e8c3c274b30b830ab079466e44ae7 (diff)
downloadgo-x-pkgsite-e6b30bf2f78149bbea1ef607321cdeed1010abc5.tar.xz
internal: support std@dev.fuzz
It is now possible to fetch std@dev.fuzz and view /std@dev.fuzz on the frontend. For golang/go#46910 Change-Id: I2fd7259840ba32ff35ca323d07412988e533ffba Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/330413 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/stdlib/testdata/dev.fuzz/src')
-rw-r--r--internal/stdlib/testdata/dev.fuzz/src/README.vendor54
-rw-r--r--internal/stdlib/testdata/dev.fuzz/src/cmd/README.vendor2
-rw-r--r--internal/stdlib/testdata/dev.fuzz/src/errors/errors.go20
-rw-r--r--internal/stdlib/testdata/dev.fuzz/src/errors/errors_test.go53
4 files changed, 129 insertions, 0 deletions
diff --git a/internal/stdlib/testdata/dev.fuzz/src/README.vendor b/internal/stdlib/testdata/dev.fuzz/src/README.vendor
new file mode 100644
index 00000000..e74fc2f3
--- /dev/null
+++ b/internal/stdlib/testdata/dev.fuzz/src/README.vendor
@@ -0,0 +1,54 @@
+Vendoring in std and cmd
+========================
+
+The Go command maintains copies of external packages needed by the
+standard library in the src/vendor and src/cmd/vendor directories.
+
+In GOPATH mode, imports of vendored packages are resolved to these
+directories following normal vendor directory logic
+(see golang.org/s/go15vendor).
+
+In module mode, std and cmd are modules (defined in src/go.mod and
+src/cmd/go.mod). When a package outside std or cmd is imported
+by a package inside std or cmd, the import path is interpreted
+as if it had a "vendor/" prefix. For example, within "crypto/tls",
+an import of "golang.org/x/crypto/cryptobyte" resolves to
+"vendor/golang.org/x/crypto/cryptobyte". When a package with the
+same path is imported from a package outside std or cmd, it will
+be resolved normally. Consequently, a binary may be built with two
+copies of a package at different versions if the package is
+imported normally and vendored by the standard library.
+
+Vendored packages are internally renamed with a "vendor/" prefix
+to preserve the invariant that all packages have distinct paths.
+This is necessary to avoid compiler and linker conflicts. Adding
+a "vendor/" prefix also maintains the invariant that standard
+library packages begin with a dotless path element.
+
+The module requirements of std and cmd do not influence version
+selection in other modules. They are only considered when running
+module commands like 'go get' and 'go mod vendor' from a directory
+in GOROOT/src.
+
+Maintaining vendor directories
+==============================
+
+Before updating vendor directories, ensure that module mode is enabled.
+Make sure GO111MODULE=off is not set ('on' or 'auto' should work).
+
+Requirements may be added, updated, and removed with 'go get'.
+The vendor directory may be updated with 'go mod vendor'.
+A typical sequence might be:
+
+ cd src
+ go get -d golang.org/x/net@latest
+ go mod tidy
+ go mod vendor
+
+Use caution when passing '-u' to 'go get'. The '-u' flag updates
+modules providing all transitively imported packages, not only
+the module providing the target package.
+
+Note that 'go mod vendor' only copies packages that are transitively
+imported by packages in the current module. If a new package is needed,
+it should be imported before running 'go mod vendor'.
diff --git a/internal/stdlib/testdata/dev.fuzz/src/cmd/README.vendor b/internal/stdlib/testdata/dev.fuzz/src/cmd/README.vendor
new file mode 100644
index 00000000..ac0df5e9
--- /dev/null
+++ b/internal/stdlib/testdata/dev.fuzz/src/cmd/README.vendor
@@ -0,0 +1,2 @@
+See src/README.vendor for information on loading vendored packages
+and updating the vendor directory.
diff --git a/internal/stdlib/testdata/dev.fuzz/src/errors/errors.go b/internal/stdlib/testdata/dev.fuzz/src/errors/errors.go
new file mode 100644
index 00000000..b8a46921
--- /dev/null
+++ b/internal/stdlib/testdata/dev.fuzz/src/errors/errors.go
@@ -0,0 +1,20 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package errors implements functions to manipulate errors.
+package errors
+
+// New returns an error that formats as the given text.
+func New(text string) error {
+ return &errorString{text}
+}
+
+// errorString is a trivial implementation of error.
+type errorString struct {
+ s string
+}
+
+func (e *errorString) Error() string {
+ return e.s
+}
diff --git a/internal/stdlib/testdata/dev.fuzz/src/errors/errors_test.go b/internal/stdlib/testdata/dev.fuzz/src/errors/errors_test.go
new file mode 100644
index 00000000..cf4df90b
--- /dev/null
+++ b/internal/stdlib/testdata/dev.fuzz/src/errors/errors_test.go
@@ -0,0 +1,53 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package errors_test
+
+import (
+ "errors"
+ "fmt"
+ "testing"
+)
+
+func TestNewEqual(t *testing.T) {
+ // Different allocations should not be equal.
+ if errors.New("abc") == errors.New("abc") {
+ t.Errorf(`New("abc") == New("abc")`)
+ }
+ if errors.New("abc") == errors.New("xyz") {
+ t.Errorf(`New("abc") == New("xyz")`)
+ }
+
+ // Same allocation should be equal to itself (not crash).
+ err := errors.New("jkl")
+ if err != err {
+ t.Errorf(`err != err`)
+ }
+}
+
+func TestErrorMethod(t *testing.T) {
+ err := errors.New("abc")
+ if err.Error() != "abc" {
+ t.Errorf(`New("abc").Error() = %q, want %q`, err.Error(), "abc")
+ }
+}
+
+func ExampleNew() {
+ err := errors.New("emit macho dwarf: elf header corrupted")
+ if err != nil {
+ fmt.Print(err)
+ }
+ // Output: emit macho dwarf: elf header corrupted
+}
+
+// The fmt package's Errorf function lets us use the package's formatting
+// features to create descriptive error messages.
+func ExampleNew_errorf() {
+ const name, id = "bimmler", 17
+ err := fmt.Errorf("user %q (id %d) not found", name, id)
+ if err != nil {
+ fmt.Print(err)
+ }
+ // Output: user "bimmler" (id 17) not found
+}